10 must-have key and mouse binding configs in Openbox

In openbox, you have a configuration file in ~/.config/openbox/rc.xml in which you can pretty much configure all the shortcuts you need in a lifetime. Here’s my top ten configurations, along with their code.

Note that all keyboard and mouse configurations go in the <keyboard>...</keyboard> and <mouse>...</mouse> sections of the configuration file respectively. The “Super” key mentioned several times is usually the Windows-logo key most people have, but could be an Apple command-key too, or maybe some other variant I don’t know about.

10. MS-Windows style DoubleClick on the titlebar application icon

Same behaviour as in Microsoft Windows, something I have gotten used to in the Windows years, double clicking the icon on the titlebar to close a window. Awesomely no problem at all in openbox:

<context name="Icon">
  <mousebind action="DoubleClick" button="Left">
    <action name="Focus"/>
    <action name="Close"/>
  </mousebind>
  <!-- ... -->
</context>

9. MS-Windows style keyboard shortcuts

Why get rid of habits I picked up rather than exploiting them? These five never left my system, neither physically nor mentally.

<keybind key="W-d"><action name="ToggleShowDesktop"/></keybind>
<keybind key="W-l"><action name="Execute"><command>xscreensaver-command -lock</command></action></keybind>
<keybind key="W-r"><action name="Execute"><command>gmrun</command></action></keybind>
<keybind key="W-e">
  <action name="Execute">
    <command>thunar</command>
    <startupnotify>
      <enabled>yes</enabled>
      <name>Thunar</name>
    </startupnotify>
  </action>
</keybind>
<keybind key="A-Tab">  <action name="NextWindow"><raise>yes</raise></action></keybind>
<keybind key="A-S-Tab"><action name="PreviousWindow"><raise>yes</raise></action></keybind>
  • Super+D: Show desktop
  • Super+L: Lock screen
  • Super+R, Using gmrun, a little popup-app to enter a program to run. There are alternatives for gnome, xfce and loads of others.
  • Super+E: Explore…. (open file manager)
  • Alt+Tab / Alt+Shift+Tab: Next / Previous window

8. Workspace movement and selection

I only use the “next” and “previous” workspace features. So in fact, the only 6 involved shortcuts are either moving to the next or previous workspace, or moving to the previous or next workspace dragging the active window along, or Alt-Tabbing through the windows on all desktops.

<keybind key="W-Right">   <action name="DesktopRight"><wrap>no</wrap></action></keybind>
<keybind key="W-Left">    <action name="DesktopLeft"><wrap>no</wrap></action></keybind>
<keybind key="S-W-Left">  <action name="SendToDesktopLeft"><wrap>no</wrap></action></keybind>
<keybind key="S-W-Right"> <action name="SendToDesktopRight"><wrap>no</wrap></action></keybind>
<keybind key="W-Tab">     <action name="NextWindow"><allDesktops>yes</allDesktops></action></keybind>
<keybind key="W-S-Tab">   <action name="PreviousWindow"><allDesktops>yes</allDesktops></action></keybind>
  • Super+Left / Super+Right: Move to previous/next desktop
  • Super+Shift+Left / Super+Shift+Right: Move current window to previous/next desktop
  • Super+Tab / Super+Shift+Tab: Next / previous window on all desktops.

7. Move window to another monitor

Some left-over habits of working with UltraMon on a dual-monitor setup on Windows:

<keybind key="C-S-A-Left">  <action name="MoveResizeTo"><monitor>2</monitor></action></keybind>
<keybind key="C-S-A-Right"> <action name="MoveResizeTo"><monitor>1</monitor></action></keybind>
  • Ctrl+Shift+Alt+Left: Move window the left monitor
  • Ctrl+Shift+Alt+Right: Move window the right monitor

6. Combining with PyTyle: Tiling within a floating layout

This is actually not part of the openbox configuration (except that pytyle is in my autostart.sh).

I have PyTyle to do my tiling. I like to use tiling to have a quick overview of some windows I will be using for the next hour or so. Usually that is an editor, a terminal and maybe a browser. Activating the tiled layout using Super+~ and deactivating it with Super-Shift-~ is very useful. Furthermore I use Super+[ and Super+] to cycle through the windows, Super+\ to make the active window master, Super+= to increase master size and Super+- to decrease master size, Super+Shift+- to remove a master and Super+Shift+= to add a master. Lastly, Super+Backspace is used to cycle through tiled layouts.-+

~/.config/pytyle/pytylerc:

Config.KEYMAP = {
    'Super-asciitilde': 'tile.default',
    'Super-Shift-asciitilde': 'untile',
 
    'Super-BackSpace': 'cycle_tiler',
    'Super-Alt-asciitilde': 'reload',
 
    'Super-plus': 'master_increase',
    'Super-minus': 'master_decrease',
 
    'Super-Shift-plus': 'add_master',
    'Super-Shift-minus': 'remove_master',
 
    'Super-backslash': 'make_active_master',
    'Super-Shift-backslash': 'win_master',
 
    'Super-bracketleft': 'win_previous',
    'Super-bracketright': 'win_next',
 
    'Super-Shift-bracketleft': 'switch_previous',
    'Super-Shift-bracketright': 'switch_next',
    }

5. Application shortcuts

The five applications I use most frequently got their own shortcut. A terminal (currently urxvt), two browsers (Chromium for regular browsing, Firefox for development), gedit for editing and Thunderbird for mail. These are the accompanying shortcuts:

<keybind key="W-b">   <action name="Execute"><command>chromium</command></action></keybind>
<keybind key="W-A-b"><action name="Execute"><command>firefox</command></action></keybind>
<keybind key="W-n">   <action name="Execute"><command>gedit</command></action></keybind>
<keybind key="W-m">   <action name="Execute"><command>thunderbird</command></action></keybind>
<keybind key="W-t">   <action name="Execute"><command>urxvt</command></action></keybind>
  • Super+T for the Terminal
  • Super+B for Chromium and Super+Alt+B for Firefox.
  • Super+M for Thunderbird mail

4. Mouse-moving and resizing with a modifier key

I have enabled Super+Left on my mouse for quick moving of windows. This means you don’t have to select the title bar to move the window around, you just click anywhere on the window while having the Super-key pressed, and drag it along. With Alt also pressed, resizing is done of windows. This means that whatever edge your mouse cursor is closest too, that direction the resize will occur, so no more sharp-shooting to get the cursor exactly at the edge or corner of a window to get it resized, just use the modifier key(s) to resize. Super+DoubleClick will maximize the window. Finally, Super+Right will open the openbox client menu.

<context name="Frame">
  <mousebind action="Press" button="W-Left">
    <action name="Focus"/>
    <action name="Raise"/>
  </mousebind>
  <mousebind action="Drag" button="W-Left">
    <action name="Move"/>
  </mousebind>
  <mousebind action="DoubleClick" button="W-Left">
    <action name="Focus" />
    <action name="Raise" />
    <action name="ToggleMaximizeFull" />
  </mousebind>
  <mousebind action="Drag" button="W-A-Left">
    <action name="Resize"/>
  </mousebind>
  <mousebind action="Press" button="W-A-Left">
    <action name="Lower"/>
    <action name="FocusToBottom"/>
    <action name="Unfocus"/>
  </mousebind>
  <mousebind action="Press" button="W-Right">
    <action name="Focus"/>
    <action name="Raise"/>
    <action name="ShowMenu">
      <menu>client-menu</menu>
    </action>
  </mousebind>
  <!-- ... -->
</context>

3. Fixed width resize

I like to be able to have my windows resized at a fixed width, e.g. browsers, file managers, mail applications, usually do the best job at about 960 pixels or about 1200 pixels wide. So, having Super+Keypad / as a shortcut for the former and Super+Alt+Keypad / for the latter, I easily put the window in a comfortable position combining with the number 1 and 2 of this post.

<keybind key="W-KP_Divide"> <action name="MoveResizeTo"><width>960</width></action></keybind>
<keybind key="W-A-KP_Divide"> <action name="MoveResizeTo"><width>1200</width></action></keybind>
  • Super+Keypad /: 960 pixels wide
  • Super+Alt+Keypad /: 1200 pixels wide

2. Maximize and Maximize Vertical

I even use Maximize vertical more often than maximize, since vertical maximization is usually actually what you want. The width of the screen mostly is either fine as it is, or can be simply adjusted using the fixed width shortcut mentioned previously.

<keybind key="W-Return">   <action name="ToggleMaximizeFull"/></keybind>
<keybind key="W-A-Return"> <action name="ToggleMaximizeVert"/></keybind>
  • Super+Enter: Maximize
  • Super+Alt+Enter: Maximize Vertically

1. Move windows to screen corners and edges

Use your numpad to move the active window to screen edges, having all keypad numbers moving the window to the edge the key points at

<keybind key="W-KP_8"><action name="MoveResizeTo"><y>0</y></action></keybind>
<keybind key="W-KP_6"><action name="MoveResizeTo"><x>-0</x></action></keybind>
<keybind key="W-KP_2"><action name="MoveResizeTo"><y>-0</y></action></keybind>
<keybind key="W-KP_4"><action name="MoveResizeTo"><x>0</x></action></keybind>
  • Super+Keypad 4: Left screen edge
  • Super+Keypad 6: Right screen edge
  • Super+Keypad 8: Top screen edge
  • Super+Keypad 2: Bottom screen edge

That’s it! If you have any shortcuts or configurations you’d like to share, go right ahead πŸ™‚

This entry was posted in Linux & BSD and tagged , , , . Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

27 Comments

  1. iveand
    Posted December 9, 2011 at 16:07 | Permalink

    I am wondering how to “disable the super key from always popping up the main menu” when used in combination with another key (so, “W-e” sometimes brings up a PCManFM window, at other times seems to only bring up the Main menu). It “should be” that the Main menu only appears upon release of the W (Super) key. Any advice on how to fix this? If not “fix” the way the Main menu is brought up, then simply disable W from calling it at all? I would much rather have consistent behavior from the other shortcuts (“W-e”, “W-d”, “W-r”, etc.)

    I am using Lubuntu 11.10. Maybe the problem lies within? I don’t see anything in the default rc.xml (named lubuntu-rc.xml) about binding the W key to Main Menu (must be deeper in the system???)

    Thanks for any help

    • drm
      Posted December 17, 2011 at 23:35 | Permalink

      Hi,

      I am not sure how to fix it, but I’m pretty sure that the super key is called something else if used as a single stroke. So you should look for that in the manual. I think it might just be “super” or something like that. Try finding that in your rc.xml and disabling it so you don’t have conflicting shortcuts.

      HTH.

  2. Alister
    Posted July 25, 2013 at 02:49 | Permalink

    That’s it! If you have any shortcuts or configurations you’d like to share, go right ahead

    These naturally follow – I might as well save someone the time from editing them themselves:

    <keybind key="W-KP_7"><action name="MoveResizeTo"><x>0</x><y>0</y></action></keybind>
    <keybind key="W-KP_9"><action name="MoveResizeTo"><x>-0</x><y>0</y></action></keybind>
    <keybind key="W-KP_1"><action name="MoveResizeTo"><x>0</x><y>-0</y></action></keybind>
    <keybind key="W-KP_3"><action name="MoveResizeTo"><x>-0</x><y>-0</y></action></keybind>
    
    • Alister
      Posted May 19, 2014 at 23:34 | Permalink

      And I now use these too… nice and easy to remember:

      • Alister
        Posted May 19, 2014 at 23:36 | Permalink

        Try again:

        • Alister
          Posted May 19, 2014 at 23:37 | Permalink

          Aaaah

          • Alister
            Posted May 19, 2014 at 23:43 | Permalink
            <keybind key="W-KP_5"><action name="ToggleMaximizeFull"></keybind>
            <keybind key="W-KP_0"><action name="Iconify"></keybind>
            
          • Erathiel
            Posted June 24, 2014 at 14:35 | Permalink

            I think you’re missing the slash at the end of the “action” tag. This should look like:

            
            
            

            Small but important difference. Without the slash Openbox returns an error upon restarting. Excellent keybindings, however! πŸ™‚

          • Erathiel
            Posted June 24, 2014 at 15:15 | Permalink

            Aww, crap πŸ˜‰ The “pre” tags don’t work well with XML. Let’s try again:

          • Erathiel
            Posted June 24, 2014 at 15:16 | Permalink

            OK, one more try:

            
            
            
            
          • Drew
            Posted November 6, 2014 at 22:14 | Permalink

            I prefer using the 5 for center, with W-Up being maximize.

            centercenter

          • Drew
            Posted November 6, 2014 at 22:14 | Permalink

            centercenter

          • Drew
            Posted November 6, 2014 at 22:15 | Permalink

            Not sure how to get this to display, trying square instead of angled brackets this time… [code]centercenter[/code]

          • Drew
            Posted November 6, 2014 at 22:19 | Permalink

            OK screw it… [keybind key=”W-KP_5″][action name=”MoveResizeTo”][x]center[/x][y]center[/y][/action][/keybind] …sorry about multiple posts

  3. Posted November 12, 2013 at 16:10 | Permalink

    thanks for this tips! gonna try to use pytyle, didn’t know that one.

  4. John
    Posted April 25, 2014 at 22:13 | Permalink

    Hi, thank you very much for this great posting.

    Among them, I am having some trouble with 10. MS-Windows style DoubleClick on the titlebar application icon. I am using lubuntu 14.10, and I added lines to the ~/.config/openbox/lubuntu-rc.xml. I restarted the openbox and rebooted, but it does not work. Do you have any idea on this?

    Thanks!

  5. Alister
    Posted April 26, 2014 at 00:07 | Permalink

    Do you have any idea on this?

    Maybe somewhere else in your configuration it is bound to a different action.

  6. John
    Posted April 26, 2014 at 00:53 | Permalink

    Hi,

    I check the file and found that your action is conflicting with the following command under context name=”Icon” in lubuntu. I am not sure why it is, but if I remove it, the command works.

      <mousebind button="Left" action="Press">
        <action name="Focus"/>
        <action name="Raise"/>
        <action name="ShowMenu">
          <menu>client-menu</menu>
        </action>
      </mousebind>
    
    • -
      Posted April 26, 2014 at 15:23 | Permalink

      I had the same problem and eventually found the same solution. I suppose it is because the Press event gets triggered before the DoubleClick event, and that the menu popping up somehow interferes with finishing the DoubleClick event…

    • drm
      Posted June 4, 2014 at 21:20 | Permalink

      Glad you found the solution πŸ™‚

      I am currently not even using window decorations anymore, because with effective bindings you don’t even really need a title bar for your windows πŸ™‚

  7. openboxer
    Posted May 25, 2014 at 20:58 | Permalink

    Is it possible to have different actions for click and double click, with the same button, in the same context?

    • drm
      Posted June 4, 2014 at 21:21 | Permalink

      I don’t see why it wouldn’t. It works for me as described in section “4. Mouse-moving and resizing with a modifier key”

  8. Jakub
    Posted June 12, 2016 at 10:39 | Permalink

    Awesome, thanks a lot! Where is the like button, please? πŸ™‚

  9. Faisal Arkan
    Posted December 12, 2016 at 03:50 | Permalink

    thanks bro, you help me alot !

  10. Posted January 28, 2017 at 05:54 | Permalink

    how do i use keyboard instead of mouse to drag windows on my monitor ?

    • Posted January 28, 2017 at 05:56 | Permalink

      like in ubuntu it would be “F7” + “arrow-key”

      • Posted January 28, 2017 at 05:57 | Permalink

        “Alt + F7” + “arrow-key”

Post a Reply to Me Cancel reply

Your email is never published nor shared.

You may use these HTML tags and attributes <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

Subscribe without commenting