Xbindkeys is a program that enables us to bind commands to certain keys or key combinations on the keyboard. Xbindkeys works with multimedia keys and is window manager / DE independent, so if you switch much, xbindkeys is very handy.

Xbindkeys is a program that enables us to bind commands to certain keys or key combinations on the keyboard. Xbindkeys works with multimedia keys and is window manager / DE independent, so if you switch much, xbindkeys is very handy.

== Installation ==

== Installation ==

+

Xbindkeys can be [[Pacman|installed]] with the package {{Pkg|xbindkeys}}, available in the [[official repositories]].

−

Xbindkeys is available in the extra repository:

+

For those who prefer a GUI, there is the {{AUR|xbindkeys_config}} package in the [[AUR]].

−

# pacman -S xbindkeys

−

−

There is also a GUI for xbindkeys [http://aur.archlinux.org/packages.php?ID=4200] which is in [[AUR]].

== Configuration ==

== Configuration ==

−

Create a file named {{Filename|.xbindkeysrc}} in your home directory:

+

Create a file named {{ic|.xbindkeysrc}} in your home directory:

touch ~/.xbindkeysrc

touch ~/.xbindkeysrc

−

Now you can either edit {{Filename|~/.xbindkeysrc}} to set keybindings, or you can do that with the GUI.

+

Alternatively, you can create a sample file by invoking

+

xbindkeys -d > ~/.xbindkeysrc

−

== Xbindkeysrc ==

+

Now you can either edit {{ic|~/.xbindkeysrc}} to set keybindings, or you can do that with the GUI.

+

+

=== Xbindkeysrc ===

To see the format of a configuration file entry, enter the following command:

To see the format of a configuration file entry, enter the following command:

xbindkeys -k

xbindkeys -k

−

A blank window will pop up. Press the key(s) to which you wish to assign a command and xbindkeys will output a handy snippet that can be entered into {{Filename|~/.xbindkeysrc}}. For example, while the blank window is open, press Alt + o to get the following output (results may vary):

+

A blank window will pop up. Press the key(s) to which you wish to assign a command and xbindkeys will output a handy snippet that can be entered into {{ic|~/.xbindkeysrc}}. For example, while the blank window is open, press Alt + o to get the following output (results may vary):

"(Scheme function)"

"(Scheme function)"

m:0x8 + c:32

m:0x8 + c:32

Alt + o

Alt + o

−

The first line represents a command. The second contains the state (0x8) and keycode (32) as reported by {{Codeline|xev}}. The third line contains the keysyms associated with the given keycodes. To use this output, copy the three lines to {{Filename|~/.xbindkeysrc}} and replace "(Scheme function)" with the command you wish to perform. Here is an example configuration file that binds Fn key combos on a laptop to {{Codeline|amixer}} commands that adjust sound volume. Note that pound (#) symbols can be used to create comments.

+

The first line represents a command. The second contains the state (0x8) and keycode (32) as reported by {{Ic|xev}}. The third line contains the keysyms associated with the given keycodes. To use this output, copy either one of the last two lines to {{ic|~/.xbindkeysrc}} and replace "(Scheme function)" with the command you wish to perform. Here is an example configuration file that binds Fn key combos on a laptop to [https://aur.archlinux.org/packages/pamixer-git/ pamixer] commands that adjust sound volume. Note that pound (#) symbols can be used to create comments.

# Increase volume

# Increase volume

−

"amixer set Master playback 1+"

+

"pamixer --increase 5"

−

m:0x0 + c:123

+

XF86AudioRaiseVolume

−

XF86AudioRaiseVolume

+

−

+

# Decrease volume

# Decrease volume

−

"amixer set Master playback 1-"

+

"pamixer --decrease 5"

−

m:0x0 + c:122

+

m:0x0 + c:122

−

XF86AudioLowerVolume

+

or

−

+

"pamixer --decrease 5"

−

# Toggle mute

+

XF86AudioLowerVolume

−

"amixer set Master toggle"

−

m:0x0 + c:121

−

XF86AudioMute

{{Tip|Use ''xbindkeys -mk'' to keep the key prompt open for multiple keypresses. Press ''q'' to quit.}}

{{Tip|Use ''xbindkeys -mk'' to keep the key prompt open for multiple keypresses. Press ''q'' to quit.}}

These instructions are valid for pretty much any one of the XF86 multimedia keys (important ones would be XF86AudioRaiseVolume, XF86AudioLowerVolume, XF86AudioPlay, XF86AudioPrev, XF86AudioNext).

These instructions are valid for pretty much any one of the XF86 multimedia keys (important ones would be XF86AudioRaiseVolume, XF86AudioLowerVolume, XF86AudioPlay, XF86AudioPrev, XF86AudioNext).

+

+

== Troubleshooting ==

+

+

If, for any reason, a hotkey you ''already'' set in {{ic|~/.xbindkeysrc}} doesn't work, open up a terminal and type the following:

+

xbindkeys -n

+

+

By pressing the non-working key, you will be able to see any error xbindkeys encounter (e.g: mistyped command/keycode,...).

Revision as of 16:34, 29 July 2013

Xbindkeys is a program that enables us to bind commands to certain keys or key combinations on the keyboard. Xbindkeys works with multimedia keys and is window manager / DE independent, so if you switch much, xbindkeys is very handy.

Configuration

Now you can either edit ~/.xbindkeysrc to set keybindings, or you can do that with the GUI.

Xbindkeysrc

To see the format of a configuration file entry, enter the following command:

xbindkeys -k

A blank window will pop up. Press the key(s) to which you wish to assign a command and xbindkeys will output a handy snippet that can be entered into ~/.xbindkeysrc. For example, while the blank window is open, press Alt + o to get the following output (results may vary):

"(Scheme function)"
m:0x8 + c:32
Alt + o

The first line represents a command. The second contains the state (0x8) and keycode (32) as reported by xev. The third line contains the keysyms associated with the given keycodes. To use this output, copy either one of the last two lines to ~/.xbindkeysrc and replace "(Scheme function)" with the command you wish to perform. Here is an example configuration file that binds Fn key combos on a laptop to pamixer commands that adjust sound volume. Note that pound (#) symbols can be used to create comments.

# Increase volume
"pamixer --increase 5"
XF86AudioRaiseVolume

# Decrease volume
"pamixer --decrease 5"
m:0x0 + c:122

or

"pamixer --decrease 5"
XF86AudioLowerVolume

Tip: Use xbindkeys -mk to keep the key prompt open for multiple keypresses. Press q to quit.

However, to actually call the keys themselves you can use tools like xdotool[2] (its in [community]) and xmacro[3] (in the AUR). Unfortunately since you'd already be holding down some modifier key (Super or Shift, for example), X will see the result as Super-XF86AudioLowerVolume which won't do anything useful. Here's a script based on xmacro and xmodmap from the xorg-server-utils package for doing this[4].

This works for calling XF86AudioLowerVolume once (assuming you're using Super-minus), but repeatedly calling it without releasing the Super key (like tapping on a volume button) doesn't work. If you'd like it to work that way, add the following line to the bottom of the script.

echo 'KeyStrPress Super_L' | xmacroplay :0

With this modified script, if you press the key combination fast enough your Super_L key will remain 'on' till the next time you hit it, which may result in some interesting side-effects. Just tap it again to remove that state, or use the original script if you want things to 'just work' and do not mind not multi-tapping on volume up/down.

These instructions are valid for pretty much any one of the XF86 multimedia keys (important ones would be XF86AudioRaiseVolume, XF86AudioLowerVolume, XF86AudioPlay, XF86AudioPrev, XF86AudioNext).

Troubleshooting

If, for any reason, a hotkey you already set in ~/.xbindkeysrc doesn't work, open up a terminal and type the following:

xbindkeys -n

By pressing the non-working key, you will be able to see any error xbindkeys encounter (e.g: mistyped command/keycode,...).