Author Topic: Using CapsLock as a prefix for Shortcuts in RC.xml  (Read 824 times)

0 Members and 1 Guest are viewing this topic.

Offline Revo86er

  • Neuling
  • *
  • Posts: 7
  • I'm new. Be nice!
  • Skill: Intermediate
Using CapsLock as a prefix for Shortcuts in RC.xml
« on: 25. March 2016, 18:22:47 »
Hey Guys,

I got a little problem here with my shortcut definitions for Openbox keyboard actions.
I want to use the caps lock key as a prefix to perform a shortcut.

I thought I'll remap the capslock key to the hyper key, done by
Code: [Select]
setxkbmap -option caps:hyperOutput from xev before swapping caps and hyper:
Code: [Select]
KeyRelease event, serial 48, synthetic NO, window 0x3400001,
    root 0xf6, subw 0x0, time 2262248, (-560,518), root:(585,681),
    state 0x2, [b]keycode 66 (keysym 0xffe5, Caps_Lock[/b]), same_screen YES,
    XLookupString gives 0 bytes:
    XFilterEvent returns: False
Output from xev after swapping caps and hyper:
Code: [Select]
KeyRelease event, serial 48, synthetic NO, window 0x3400001,
    root 0xf6, subw 0x0, time 2364568, (-112,127), root:(1033,290),
    state 0x40, [b]keycode 66 (keysym 0xffed, Hyper_L[/b]), same_screen YES,
    XLookupString gives 0 bytes:
    XFilterEvent returns: False
Alright, so far, so good. Defining an action with the Hyper Key in RC.xml, like:
Code: [Select]
    </keybind>
    <keybind key="H-x">
      <action name="Execute">
        <command>gmrun</command>
      </action>
    </keybind>
works actually!

But, when I use the super key and push x gmrun gets execute as well. In some way, the super key works as hyper as well. Hmm, is that the right assumption or what do I miss here?

Btw, here the xev output from Super.
Code: [Select]
KeyRelease event, serial 48, synthetic NO, window 0x3400001,
    root 0xf6, subw 0x0, time 2657169, (-294,402), root:(851,565),
    state 0x40, [b]keycode 133 (keysym 0xffeb, Super_L[/b]), same_screen YES,
    XLookupString gives 0 bytes:
    XFilterEvent returns: False
Well alright, I noticed the keycode from caps lock didn't change after using the setxkbmap command. In both conditions its  keycode 66 (even after setxkbmap -option caps:none).

Relying on http://openbox.org/wiki/Help:Bindings#Keys it's actually possible to use the key code, I changed my RC.xml example to:
Code: [Select]
    </keybind>
    <keybind key="0x42-x">
      <action name="Execute">
        <command>gmrun</command>
      </action>
    </keybind>
But this doesn't work at all.  Don't know which part I've missed but I'm grateful for every hint guys!
Cheers
« Last Edit: 25. March 2016, 18:27:35 by Revo86er »

Offline Revo86er

  • Neuling
  • *
  • Posts: 7
  • I'm new. Be nice!
  • Skill: Intermediate
Re: Using CapsLock as a prefix for Shortcuts in RC.xml
« Reply #1 on: 26. March 2016, 00:13:32 »
Output 'xmodmap with setxkbmap -option caps:hyper'
Code: [Select]
    xmodmap:  up to 5 keys per modifier, (keycodes in parentheses):
   
    shift       Shift_L (0x32),  Shift_R (0x3e)
    lock     
    control     Control_L (0x25),  Control_R (0x69)
    mod1        Alt_L (0x40),  Alt_R (0x6c),  Meta_L (0xcd)
    mod2        Num_Lock (0x4d)
    mod3     
    mod4        Hyper_L (0x42),  Super_L (0x85),  Super_R (0x86),  Super_L (0xce),  Hyper_L (0xcf)
    mod5        ISO_Level3_Shift (0x5c),  Mode_switch (0xcb)

Offline Revo86er

  • Neuling
  • *
  • Posts: 7
  • I'm new. Be nice!
  • Skill: Intermediate
Re: Using CapsLock as a prefix for Shortcuts in RC.xml
« Reply #2 on: 26. March 2016, 10:44:29 »
Got it working  :)

I've created a key map file, by
Code: [Select]
xmodmap -pke > ~/.Xmodmapthen I added on the end of ~/.Xmodmap:
Code: [Select]
clear      lock
clear      mod1
clear      mod2
clear      mod3
clear      mod4
clear      mod5
keycode      66 = Hyper_L
add     control = Control_L Control_R
add        mod1 = Alt_L Alt_R Meta_L
add        mod2 = Num_Lock
add        mod3 = Hyper_L
add        mod4 = Super_L Super_R
add        mod5 = Mode_switch ISO_Level3_Shift

I executed following command:
Code: [Select]
setxkbmap -option caps:hyper &&  xmodmap ~/.Xmodmapand it works

the new output of xmodmap is,
Code: [Select]
shift       Shift_L (0x32),  Shift_R (0x3e)
lock     
control     Control_L (0x25),  Control_R (0x69)
mod1        Alt_L (0x40),  Alt_R (0x6c),  Alt_L (0xcc),  Meta_L (0xcd)
mod2        Num_Lock (0x4d)
mod3        Hyper_L (0x42),  Hyper_L (0xcf)
mod4        Super_L (0x85),  Super_R (0x86),  Super_L (0xce)
mod5        ISO_Level3_Shift (0x5c),  Mode_switch (0xcb)

The only weird thing is openbox takes around 15~20 secs to execute the "xmodmap ~/.Xmodmap" command. The CPU run's up like I'm starting three firefox sessions with each hundred tabs  :o
And if I put it into ~/.config/openbox/autostart it will mess up my conky panels, seems like a graphical issue.

Would be still nice to know what I've made wrong while using the keycode in RC.xml as I described in the first post.
« Last Edit: 26. March 2016, 10:56:08 by Revo86er »