You are not logged in.

#1 2021-02-27 20:02:44

Registered: 2015-09-29
Posts: 5,532

Openbox rc.xml tips & tricks

Share & discuss tips & tricks for setting up keybinds, application rules etc.!


This is probably the most powerful part of Openbox.
Especially the If and Foreach actions therein.

Problem: I have an application with keybinds that cannot be changed, namely Signal for Linux desktop.
One of these keybinds has been my probably most used keybind for a long time, namely
Shift-Return to open an application launcher.

Solution: Openbox allows me to execute different actions depending on which window is focused via
the If action.

In your rc.xml, locate the <keybind> that you want to modify. In my case, it looks like this after the modification:

    <keybind key="S-Return">
      <action name="If">
        <query target="focus">
            <class type="exact">Signal</class>
            <action name="Execute"><command>xdotool type "
            <action name="Execute"><command>~/bin/dmenu_run_hist</command>
  • If the window with the exact class name "Signal" is focused, type Return (Shift is not required since the user invoking this keybind is still holding it down).
    Xdotool does not always play perfectly with all applications; I tried 'key Return' with and without Shift but it didn't work, so I resorted to making it type out a newline, that's what looks a little broken in the code block.

  • Otherwise, open the app launcher

Simple enough despite the obnoxious XML syntax.

One niggle remains: I see no way to let the key combination pass through if the "If" query returns False - neither implicitly (Openbox "eats" the event) nor explicitly with xdotool.

Warning: 'xdotool key' does not work (as expected) on all windows/applications.

Give to COVAX! Here or here. (explanation)


Board footer

Powered by FluxBB