Difference between revisions of "Extra keyboard keys/Xorg"
Kynikos.bot (talk | contribs) (add Turkish interlanguage link) |
m (→Map keycodes to actions: terminology: keycodes -> keysyms) |
||
(19 intermediate revisions by 8 users not shown) | |||
Line 1: | Line 1: | ||
− | [[Category: | + | [[Category:Keyboards]] |
[[Category:X Server]] | [[Category:X Server]] | ||
+ | [[ru:Extra Keyboard Keys in Xorg]] | ||
[[tr:X_sunucusunda_ek_klavye_tuşları]] | [[tr:X_sunucusunda_ek_klavye_tuşları]] | ||
− | |||
− | |||
{{Article summary start}} | {{Article summary start}} | ||
{{Article summary text|A general overview of how to assign actions to extra keyboard keys in [[Xorg]].}} | {{Article summary text|A general overview of how to assign actions to extra keyboard keys in [[Xorg]].}} | ||
{{Article summary heading|Related}} | {{Article summary heading|Related}} | ||
+ | {{Article summary wiki|Extra Keyboard Keys}} | ||
+ | {{Article summary wiki|Extra Keyboard Keys in Console}} | ||
+ | {{Article summary wiki|Map scancodes to keycodes}} | ||
{{Article summary wiki|Xorg}} | {{Article summary wiki|Xorg}} | ||
{{Article summary wiki|Xmodmap}} | {{Article summary wiki|Xmodmap}} | ||
− | |||
− | |||
{{Article summary end}} | {{Article summary end}} | ||
− | When we are in a graphical environment we may want | + | When we are in a graphical environment we may want to execute a command when certain key combination is pressed. There are some ways of doing that and they are covered on this page. |
− | + | == Map keysyms to actions == | |
− | + | {{Merge|Keyboard Shortcuts#X11_2|same topic}} | |
− | |||
− | |||
− | |||
− | + | There are multiple ways to do that: | |
− | + | * The most portable way using low level tools, such as [[acpid]]. Not all keys are supported, but configuration in uniform way is possible for keyboard keys, power adapter connection and even headphone jack (un)plugging events. | |
− | + | * The universal way using [[Xorg]] utilities (e.g. [[Xbindkeys]]) and eventually your desktop environment or window manager tools. | |
− | The | + | * The quicker way using a third-party program to do everything in GUI, such as the Gnome Control Center or [[Keytouch]]. |
− | |||
− | |||
− | |||
− | + | === Using your Desktop Environment tools === | |
− | + | ==== Gnome ==== | |
− | |||
− | |||
− | |||
− | + | Gnome Control Center is quite complete for the extra keyboard keys management. In fact it can directly detect scancodes which means that it can map any key seen by the kernel. | |
− | == | + | ==== KDE ==== |
− | |||
− | |||
− | + | Keyboard shortcuts can be configured in '''System Settings''' -> '''Shortcuts and Gestures'''. | |
− | |||
− | = | + | ==== Xfce4 ==== |
− | + | You can change the keyboard shortcuts in Keyboard Settings, which can be run using {{Ic|xfce4-keyboard-settings}}. | |
− | |||
− | |||
− | === | + | ==== Openbox ==== |
− | |||
− | + | You can set keyboard shortcuts and actions in the keyboard section of your {{ic|~/.config/openbox/rc.xml}} file. For example, the following will lower the volume with a media key: | |
− | You can | ||
− | |||
− | |||
<keybind key="XF86AudioLowerVolume"> | <keybind key="XF86AudioLowerVolume"> | ||
− | + | <action name="Execute"> | |
− | + | <execute>amixer set Master 5- unmute</execute> | |
− | + | </action> | |
</keybind> | </keybind> | ||
+ | |||
For more information, please visit [http://urukrama.wordpress.com/openbox-guide/#Key_mouse urukrama's Openbox Guide] or the [http://openbox.org/wiki/Help:Actions Openbox Wiki]. | For more information, please visit [http://urukrama.wordpress.com/openbox-guide/#Key_mouse urukrama's Openbox Guide] or the [http://openbox.org/wiki/Help:Actions Openbox Wiki]. | ||
− | ===PekWM=== | + | You can use obkey utility from [[AUR]] for easy configuration. |
+ | |||
+ | ==== PekWM ==== | ||
+ | |||
Setting keys in PekWM is accomplished by editing your {{ic|~/.pekwm/keys}} file. For example, adding the following at the bottom of the Global section will lower the volume with a media key: | Setting keys in PekWM is accomplished by editing your {{ic|~/.pekwm/keys}} file. For example, adding the following at the bottom of the Global section will lower the volume with a media key: | ||
+ | |||
KeyPress = "XF86AudioLowerVolume" { Actions = "exec amixer set Master 5%- unmute &" } | KeyPress = "XF86AudioLowerVolume" { Actions = "exec amixer set Master 5%- unmute &" } | ||
− | ===Xmonad=== | + | ==== Xmonad ==== |
− | If you use Xmonad as a stand alone window manager, you can edit the xmonad.hs to add | + | |
+ | If you use Xmonad as a stand alone window manager, you can edit the xmonad.hs to add unbound keyboard keys. You just need to find the Xf86 name of the key (such as XF86PowerDown) and look it up in {{Ic|/usr/include/X11/XF86keysym.h}}. It will give you a keycode (like 0x1008FF2A) which you can use to add a line like the following in the keybindings section of your {{ic|xmonad.hs}}: | ||
+ | |||
((0, 0x1008FF2A), spawn "sudo pm-suspend") | ((0, 0x1008FF2A), spawn "sudo pm-suspend") | ||
− | ==Using third-party programs== | + | ==== i3 ==== |
− | ===keytouch=== | + | |
+ | Open your ~/.i3/config and just bind the keysym to a command: | ||
+ | |||
+ | bindsym XF86MonBrightnessDown exec xbacklight -dec 10 | ||
+ | bindsym Print exec scrot | ||
+ | |||
+ | === Using third-party programs === | ||
+ | |||
+ | ==== sxhkd ==== | ||
+ | |||
+ | A simple X hotkey daemon with a powerful and compact configuration syntax. | ||
+ | |||
+ | Available as {{aur|sxhkd-git}} and {{aur|sxhkd}} in [[AUR]]. | ||
+ | |||
+ | ==== keytouch ==== | ||
+ | |||
KeyTouch is a program which allows you to easily configure the extra function keys of your keyboard. This means that you can define, for every individual function key, what to do if it is pressed. | KeyTouch is a program which allows you to easily configure the extra function keys of your keyboard. This means that you can define, for every individual function key, what to do if it is pressed. | ||
''See the detailed article: [[keytouch]].'' | ''See the detailed article: [[keytouch]].'' | ||
− | === | + | ==== actkbd ==== |
+ | |||
From [http://users.softlab.ece.ntua.gr/~thkala/projects/actkbd/ actkbd home page]: | From [http://users.softlab.ece.ntua.gr/~thkala/projects/actkbd/ actkbd home page]: | ||
− | + | :'''actkbd''' (available [https://aur.archlinux.org/packages.php?ID=8056 in AUR]) is a simple daemon that binds actions to keyboard events. It recognises key combinations and can handle press, repeat and release events. Currently it only supports the linux-2.6 evdev interface. It uses a plain-text configuration file which contains all the bindings. | |
− | '''actkbd''' (available [https://aur.archlinux.org/packages.php?ID=8056 in AUR]) is a simple daemon that binds actions to keyboard events. It recognises key combinations and can handle press, repeat and release events. Currently it only supports the linux-2.6 evdev interface. It uses a plain-text configuration file which contains all the bindings. | ||
− | |||
A sample configuration and guide is available [http://users.softlab.ece.ntua.gr/~thkala/projects/actkbd/latest/README here]. | A sample configuration and guide is available [http://users.softlab.ece.ntua.gr/~thkala/projects/actkbd/latest/README here]. | ||
+ | ==== xbindkeys ==== | ||
− | + | ''[[xbindkeys]]'' allows advanced mapping of keysyms to actions independently of the Desktop Environment. | |
− | ''[[xbindkeys]]'' | ||
− | |||
− |
Revision as of 12:33, 12 October 2013
Template:Article summary start Template:Article summary text Template:Article summary heading Template:Article summary wiki Template:Article summary wiki Template:Article summary wiki Template:Article summary wiki Template:Article summary wiki Template:Article summary end
When we are in a graphical environment we may want to execute a command when certain key combination is pressed. There are some ways of doing that and they are covered on this page.
Contents
Map keysyms to actions
There are multiple ways to do that:
- The most portable way using low level tools, such as acpid. Not all keys are supported, but configuration in uniform way is possible for keyboard keys, power adapter connection and even headphone jack (un)plugging events.
- The universal way using Xorg utilities (e.g. Xbindkeys) and eventually your desktop environment or window manager tools.
- The quicker way using a third-party program to do everything in GUI, such as the Gnome Control Center or Keytouch.
Using your Desktop Environment tools
Gnome
Gnome Control Center is quite complete for the extra keyboard keys management. In fact it can directly detect scancodes which means that it can map any key seen by the kernel.
KDE
Keyboard shortcuts can be configured in System Settings -> Shortcuts and Gestures.
Xfce4
You can change the keyboard shortcuts in Keyboard Settings, which can be run using xfce4-keyboard-settings
.
Openbox
You can set keyboard shortcuts and actions in the keyboard section of your ~/.config/openbox/rc.xml
file. For example, the following will lower the volume with a media key:
<keybind key="XF86AudioLowerVolume"> <action name="Execute"> <execute>amixer set Master 5- unmute</execute> </action> </keybind>
For more information, please visit urukrama's Openbox Guide or the Openbox Wiki.
You can use obkey utility from AUR for easy configuration.
PekWM
Setting keys in PekWM is accomplished by editing your ~/.pekwm/keys
file. For example, adding the following at the bottom of the Global section will lower the volume with a media key:
KeyPress = "XF86AudioLowerVolume" { Actions = "exec amixer set Master 5%- unmute &" }
Xmonad
If you use Xmonad as a stand alone window manager, you can edit the xmonad.hs to add unbound keyboard keys. You just need to find the Xf86 name of the key (such as XF86PowerDown) and look it up in /usr/include/X11/XF86keysym.h
. It will give you a keycode (like 0x1008FF2A) which you can use to add a line like the following in the keybindings section of your xmonad.hs
:
((0, 0x1008FF2A), spawn "sudo pm-suspend")
i3
Open your ~/.i3/config and just bind the keysym to a command:
bindsym XF86MonBrightnessDown exec xbacklight -dec 10 bindsym Print exec scrot
Using third-party programs
sxhkd
A simple X hotkey daemon with a powerful and compact configuration syntax.
Available as sxhkd-gitAUR and sxhkdAUR in AUR.
keytouch
KeyTouch is a program which allows you to easily configure the extra function keys of your keyboard. This means that you can define, for every individual function key, what to do if it is pressed.
See the detailed article: keytouch.
actkbd
From actkbd home page:
- actkbd (available in AUR) is a simple daemon that binds actions to keyboard events. It recognises key combinations and can handle press, repeat and release events. Currently it only supports the linux-2.6 evdev interface. It uses a plain-text configuration file which contains all the bindings.
A sample configuration and guide is available here.
xbindkeys
xbindkeys allows advanced mapping of keysyms to actions independently of the Desktop Environment.