Difference between revisions of "Xbindkeys"

From ArchWiki
Jump to: navigation, search
m (Corrected 2 small mistakes)
(overall cleanup; added more info about command output + a longer example config)
Line 8: Line 8:
 
== Xbindkeys ==  
 
== Xbindkeys ==  
  
Xbindkeys is a program that enables us to assign specific functions, to a certain key on the keyboard. Xbindkeys work 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 ==
  
You can install xbindkeys from the standard repo's
+
Xbindkeys is available in the extra repository:
 
  # pacman -S xbindkeys
 
  # pacman -S xbindkeys
  
And you can also install the gui for xbindkeys [http://aur.archlinux.org/packages.php?ID=4200] which is in [[AUR]]
+
There is also a GUI for xbindkeys [http://aur.archlinux.org/packages.php?ID=4200] which is in [[AUR]].
  
 
== Configuration ==
 
== Configuration ==
  
Create a file .xbindkeysrc in your home dir
+
Create a file named {{Filename|.xbindkeysrc}} in your home directory:
  touch ~/.xbindkeysrc
+
touch ~/.xbindkeysrc
  
Now you can either use the .xbindkeysrc to set keybindings or you can do that with the GUI
+
Now you can either edit {{Filename|~/.xbindkeysrc}} to set keybindings, or you can do that with the GUI.
  
 
== Xbindkeysrc ==
 
== Xbindkeysrc ==
  
 +
To see the format of a configuration file entry, enter the following command:
 +
xbindkeys -k
  
If you want to assign a shortcut key to a key run;
+
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):
  xbindkeys -k
+
"(Scheme function)"
 +
    m:0x8 + c:32
 +
    Alt + o
  
Give the command, you get the blank window that you want to assign a shortcut key when the selected key. For example i want to assign 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.
I just run xbindkeys -k and press the key combination, this gives the following output:
+
# Increase volume
  "(Scheme function)"
+
"amixer set Master playback 1+"
     m: alt + o: 120
+
    m:0x0 + c:123
     NoSymbol
+
    XF86AudioRaiseVolume
 +
   
 +
# Decrease volume
 +
"amixer set Master playback 1-"
 +
    m:0x0 + c:122
 +
    XF86AudioLowerVolume
 +
 +
# Toggle mute
 +
"amixer set Master toggle"
 +
     m:0x0 + c:121
 +
     XF86AudioMute
  
( Use ''xbindkeys -mk'' to keep the key promt open, ^Q exits )
+
{{Tip|Use ''xbindkeys -mk'' to keep the key prompt open for multiple keypresses. Press ''q'' to quit.}}
 
+
Now you can copy these three lines to .xbindkeysrc and fill an command in "(Scheme function)" , then you will get something like this:
+
  "amixer set Master toggle"
+
    m:0x0 + c:160
+
    NoSymbol
+
 
+
The first line represents  the command , the second the key , the third the symbol ( but there isn't any).
+
  
 
== GUI method ==
 
== GUI method ==
  
If you installed the xbindkeys_config package, just run :
+
If you installed the xbindkeys_config package, just run:
  xbindkeys_config  
+
xbindkeys_config
  
 
== Usage ==
 
== Usage ==
  
Once your done configuring your keys edit your ~/.xinitrc and place  
+
Once you're done configuring your keys, edit your {{Filename|~/.xinitrc}} and place  
  xbindkeys &
+
xbindkeys &
Before your windows manager / DE starts
+
 
 +
before the line that starts your window manager or DE.

Revision as of 04:53, 17 August 2010

Template:I18n links start Template:I18n entry Template:I18n entry Template:I18n links end

Xbindkeys

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

Xbindkeys is available in the extra repository:

# pacman -S xbindkeys

There is also a GUI for xbindkeys [1] which is in AUR.

Configuration

Create a file named Template:Filename in your home directory:

touch ~/.xbindkeysrc

Now you can either edit Template:Filename 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 Template:Filename. 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 Template:Codeline. The third line contains the keysyms associated with the given keycodes. To use this output, copy the three lines to Template:Filename 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 Template:Codeline commands that adjust sound volume. Note that pound (#) symbols can be used to create comments.

# Increase volume
"amixer set Master playback 1+"
    m:0x0 + c:123
    XF86AudioRaiseVolume

# Decrease volume
"amixer set Master playback 1-"
    m:0x0 + c:122
    XF86AudioLowerVolume

# Toggle mute
"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.

GUI method

If you installed the xbindkeys_config package, just run:

xbindkeys_config

Usage

Once you're done configuring your keys, edit your Template:Filename and place

xbindkeys &

before the line that starts your window manager or DE.