5

I want to have my super key start dmenu. I have set it as a keyboard shortcut in my rc.xml as follows:

<keybind key="0xffeb">
      <action name="Execute">
        <command>dmenu_run</command>
      </action>
</keybind>

I tried specifying it in the key attribute as W, W-, and 0xffeb, but none of these worked.
W responds to pressing the letter w, and the others appear to do nothing.

I want the shortcut to trigger when the super key is pressed and released on it's own. Is this possible?


This is cross posted from super user as per the guidelines here. I've read this question: Super key as shortcut - Openbox, but I didn't see any useful information in it.

5

I ended up using xcape, a utility designed to do exactly this:

xcape allows you to use a modifier key as another key when pressed and released on its own. Note that it is slightly slower than pressing the original key, because the pressed event does not occur until the key is released.

Quoted from the xcape readme

Using xcape, you can assign the press and release of a modifier key to a different key or even a sequence of keys. For example, you can assign Linux key Super to a placeholder shortcut like ⎈ Ctrl⇧ Shift⎇ AltLinux key SuperD with:

xcape -e 'Super_L=Control_L|Shift_L|Alt_L|Super_L|D'

Now when you press and release Linux key Super without pressing any other keys, xcape will send keyboard events simulating presses of ⎈ Ctrl⇧ Shift⎇ AltLinux key SuperD (holding all the modifier keys down as if you pressed them like a shortcut).

If you press Linux key Super and another key (or hold Linux key Super too long, the default timeout is 500 ms), xcape will pass the keyboard events through as is, without firing extra keys.

If you put the placeholder shortcut in rc.xml, it will run when Linux key Super and only Linux key Super is pressed.

<keybind key="C-A-S-W-d">
      <action name="Execute">
          <command>dmenu_run</command>
      </action>
</keybind>

Other shortcuts involving Linux key Super will not be affected.

Note that you'll have to run xcape each time you boot, so you may want to put it somewhere like ~/.config/openbox/autostart where it will be run automatically.

2

Run xev and press your super key to get the appropriate key name. Mine is Super_L according to the output:

KeyRelease event, serial 48, synthetic NO, window 0x3600001,
    root 0x91, subw 0x0, time 1648471775, (167,-8), root:(927,138),
    state 0x50, keycode 133 (keysym 0xffeb, Super_L), same_screen YES,
    XLookupString gives 0 bytes: 
    XFilterEvent returns: False

Assuming yours is the same, this should work with a single key press of the super key (aka windows key):

<keybind key="Super_L">
      <action name="Execute">
        <command>dmenu_run</command>
      </action>
</keybind>

Save the file and run killall -SIGUSR2 openbox to reload the configuration.

As an aside, I am working in the config file for the local user at $HOME/.config/openbox/lxde-rc.xml. Using W only registers as the super key when used in combination, but Super_L works on its own instead of being read as the letter w.

  • This is closer, but it appears to run on key press instead of key release. So other shortcuts which use super no longer work.. – gandalf3 Jul 11 '15 at 10:02
  • I overlooked the release part. I would still like to know if there is a way to do this natively in openbox, because it seems like a feature that should be included. For example, it would be great if a chrooted keybinding could execute a command followed by breakchroot, all in one key press. Currently, all actions seem to require an additional key press. openbox.org/wiki/Help:Bindings#Chrooting_key_chains – iyrin Jul 11 '15 at 11:34
  • Yes, that would be nice. If you find a way, I'll probably accept it ;) Though for now xcape is good enough for me. – gandalf3 Jul 11 '15 at 19:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.