Help:Bindings

From Openbox

(Difference between revisions)
Jump to: navigation, search
(Mouse binding syntax)
(Mouse binding syntax)
Line 187: Line 187:
 
Any number of <mousebind>s may appear within a <context>, and any number of [[Help:Actions| Actions]] may appear within a <mousebind>.
 
Any number of <mousebind>s may appear within a <context>, and any number of [[Help:Actions| Actions]] may appear within a <mousebind>.
  
=== Contexts ===
+
=== Context ===
 
Mouse bindings, unlike key bindings, are made within '''contexts'''.  A context represents what you are clicking/dragging on with your mouse.
 
Mouse bindings, unlike key bindings, are made within '''contexts'''.  A context represents what you are clicking/dragging on with your mouse.
  
Line 233: Line 233:
 
* '''MoveResize'''
 
* '''MoveResize'''
 
** Bindings in this special context are available while a window is being moved or resized interactively
 
** Bindings in this special context are available while a window is being moved or resized interactively
 +
 +
=== Button ===
 +
The button specifies which mouse button is used to trigger this mouse binding.
 +
 +
The named buttons are: <code>Left</code>, <code>Right</code>, <code>Middle</code>, <code>Up</code>, <code>Down</code>.  To bind more than 5 buttons, use <code>Button6</code>, <code>Button7</code> and so on.
 +
 +
=== Event ===
 +
The event for a mouse binding specifies what mouse event triggers the actions contained within.
 +
 +
==== Press ====
 +
The mouse button is pressed down in the specified context

Revision as of 22:50, 3 June 2007

Key and mouse bindings are created in your ~/.config/openbox/rc.xml file. You should copy the file from /etc/xdg/openbox/rc.xml to ~/.config/openbox/rc.xml to edit it, if that file does not already exist.

Key bindings and mouse bindings both use Actions to specify what they will do. There are a lot of actions available to you. Here we'll talk about how to write a generic key binding, or mouse binding. See the actions documentation for details about what actions are available to use and their varied options.

Contents

Key bindings

Key bindings are found in the <keyboard> section of your rc.xml configuration file. Any bindings outside of that section are not valid and will be ignored.

Here are a few example key bindings from the default configuration file, to give us an idea of what we'll be talking about:

<keyboard>
  <keybind key="A-F4">
    <action name="Close"/>
  </keybind>
  <keybind key="A-Escape">
    <action name="Lower"/>
    <action name="FocusToBottom"/>
    <action name="Unfocus"/>
  </keybind>
  <keybind key="A-space">
    <action name="ShowMenu"><menu>client-menu</menu></action>
  </keybind>
</keyboard>

Key binding syntax

A key binding is specified as follows:

<keyboard>
  ...
  <keybind key="KEY-COMBO">
    ...ACTIONS...
  </keybind>
  ...
</keyboard>

Key combinations

KEY-COMBO is the key combination which you want to bind to the actions. The format for the KEY-COMBO is: Modifier-Modifier-Key. Any number of modifiers (0 or more) can be used together, and they are each separated by a "-".

The Key is the name of the key, such as "a", "space", "Escape", or "F1". You can find the name of any key by using the xev command in a terminal, pressing the desired key, and watching the output from xev in the terminal.

Modifier keys
S Shift key
C Control key
A Alt key
W Super key (Usually bound to the Windows key on keyboards which have one)
M Meta key
H Hyper key (If it is bound to something)

You can also use Mod1 through Mod5 to directly select a modifier mask (e.g. Mod1Mask), but this is for advanced users who have customized their modifier mapping with xmodmap.

Actions

The ACTIONS can be any number of actions. They will generally be executed in order from the first to the last.

Key chains

You can create Emacs-style key chains simply by nesting key bindings inside each other. Here's an example:

  <keybind key="C-f">
    <keybind key="x">
      <action name="ToggleMaximizeFull"/>
    </keybind>
    <keybind key="s">
      <action name="ToggleShade"/>
    </keybind>
  </keybind>

In order to maximize a window using this key binding you would press the Control key and the "f" key together (which is written as C-f), then you would release everything and press the "x" key.

To shade a window, you would press Control and the "f" key together, and then release everything and press the "s" key.

You can create key chains within key chains, with as many levels as you want, if you wish to.

The key chain dialog

(thumbnail)
The key chain dialog

When you start a key chain, after a short delay, a small dialog will appear in the top left corner of the screen to show you where you are in the key chain.

As long as you are in a key chain, other key bindings will not work except the ones found inside the key chain.

Cancelling key chains

If you leave Openbox in a key chain state for too long without completing it, Openbox will cancel the key chain and restore your normal key bindings.

You can also use the "C-g" (Control key and "g" key together), in the default configuration, to cancel any key chain which you are in. The choice of this key is controlled by the <chainQuitKey> in the <keyboard> section of the rc.xml configuration file.

The default <chainQuitKey> is defined as this:

<keyboard>
  <chainQuitKey>C-g</chainQuitKey>
  ...
</keyboard>

Chrooting key chains

By default, once you get to the terminal end of a key chain, and run some actions with it, Openbox will exit the key chain and return to the normal key bindings. With a "chrooted" key chain, Openbox will not leave the key chain automatically, and when you use keys further along the chain, it will stay within the chroot.

There are a number of examples of how this could be used, so you can get a better idea. You could use this to use the arrow keys to change desktops, for instance. A key chain setup such as:

  <keybind key="C-A-d" chroot="true">                                           
    <keybind key="Up"><action name="DesktopUp"><dialog>no</dialog></action></keybind>                 
    <keybind key="Down"><action name="DesktopDown"><dialog>no</dialog></action></keybind>                 
    <keybind key="Left"><action name="DesktopLeft"><dialog>no</dialog></action></keybind>                 
    <keybind key="Right"><action name="DesktopRight"><dialog>no</dialog></action></keybind>                 
    <keybind key="Escape"><action name="BreakChroot"/></keybind>              
  </keybind>

This key chain would mean that when you pressed and released Control-Alt-D, you would enter a chroot. From then on, other key bindings would not function, but the Arrow keys by themselves would move your around your desktops. Pressing Escape or Control-G (in the default configuration) would take you back out of the chroot and return your key bindings to normal.

Once you enter a chrooted key chain, Openbox will not time out and leave the chain. You will remain inside the key chain until you use a BreakChroot action, as shown here, or press the <chainQuitKey>. BreakChroot actions are different from the <chainQuitKey> in that they will only break out of one chroot. So, if you have nested chroots, you can break out of only as many as you want, by placing 1 or more BreakChroot actions in a key binding.

Key quoting with Chroots

Another use for chroots is "key quoting". This is used when you run an Openbox session in a window, such as a VNC client. In order to use key bindings inside the VNC, generally, you have to make sure that they are different from the ones in your main Openbox session.

With key quoting, you can use the same key bindings in both. Here's an example:

  <keybind key="C-A-q" chroot="true">
    <keybind key="C-A-q"><action name="BreakChroot"/></keybind>
  </keybind>

With this example, when you pressed Control-Alt-Q, Openbox would enter the chroot. Then your normal Openbox key bindings would stop working and would instead be passed through to the VNC session (assuming you have it focused). When you were done, you could press Control-Alt-Q again, and your normal key bindings would be restored in you main Openbox session.

Mouse bindings

Mouse bindings are used to bind Actions to mouse events. These are used to control and define most of Openbox's interactive behavior, from what happens when you drag a window's titlebar, to when you press a window's Close button.

Mouse bindings are found in the <mouse> section of your rc.xml configuration file. Any bindings outside of that section are not valid and will be ignored.

To get us started, here are a few example mouse bindings from the default configuration file:

<mouse>
  <context name="Titlebar">
    <mousebind button="Left" action="Press">
      <action name="Focus"/>
      <action name="Raise"/>
    </mousebind>
    <mousebind button="Left" action="Click">
      <action name="Unshade"/>
    </mousebind>
    <mousebind button="Left" action="Drag">
      <action name="Move"/>
    </mousebind>
    <mousebind button="Left" action="DoubleClick">
      <action name="ToggleMaximizeFull"/>
    </mousebind>

    <mousebind button="Up" action="Click">
      <action name="Shade"/>
      <action name="FocusToBottom"/>
      <action name="Unfocus"/>
    </mousebind>
    <mousebind button="Down" action="Click">
      <action name="Unshade"/>
    </mousebind>
  </context>
</mouse>

Mouse binding syntax

A mouse binding is specified as follows:

<mouse>
  ...
  <context name="CONTEXT">
    <mousebind button="BUTTON" action="EVENT">
      ...ACTIONS...
    </mousebind>
  </context>
  ...
</mouse>

Any number of <mousebind>s may appear within a <context>, and any number of Actions may appear within a <mousebind>.

Context

Mouse bindings, unlike key bindings, are made within contexts. A context represents what you are clicking/dragging on with your mouse.

  • Frame
    • The entire window frame for any window (except the desktop). This includes both the window decorations (if any) and the application window itself.
      • Note: When a button is bound in this context, the clicks will not be passed through to the application. Use with care.
  • Client
    • The application window, inside the window decorations.
      • Note: When a button is bound in this context, the clicks will be passed through to the application. However, because of this, only "Press" events can be used for this context.
  • Desktop
    • The desktop, or background, regardless of if you use a program to place icons on your desktop or not (such as in KDE and GNOME). This is also called the "root window" frequently.
  • Root
    • This works similarly to the Desktop context. However, this is a special context for bindings you only want to work only when you don't have a program running to place icons on your desktop. Generally this is only used for the root menus, so that they won't override the menus provided by your desktop icons.
  • Titlebar
    • The decorations on the top of each application window
  • Top, Bottom, Left, Right
    • The top, bottom, left or right edge of a window
  • TLCorner, TRCorner, BLCorner, BRCorner
    • The top-left, top-right, bottom-left or bottom-right corner of a window
  • Icon
    • The window icon shown in window titlebars
  • Iconify
    • The iconify button shown in window titlebars
  • Maximize
    • The maximize button shown in window titlebars
  • Close
    • The close button shown in window titlebars
  • AllDesktops
    • The all-desktops (omnipresent) button shown in window titlebars
  • Shade
    • The shade button shown in window titlebars
  • MoveResize
    • Bindings in this special context are available while a window is being moved or resized interactively

Button

The button specifies which mouse button is used to trigger this mouse binding.

The named buttons are: Left, Right, Middle, Up, Down. To bind more than 5 buttons, use Button6, Button7 and so on.

Event

The event for a mouse binding specifies what mouse event triggers the actions contained within.

Press

The mouse button is pressed down in the specified context

Personal tools