Skip to content
Frsf Nrrg edited this page Jun 12, 2018 · 9 revisions

Format

bindsym [--release] [--locked] [<Modifiers>+]<Keysyms> <command>
bindcode [--release] [--locked] [<Modifiers>+]<Keycodes> <command>

<Modifiers> is a (possibly empty) + separated list of modifier bit flag names. (Shift=0x01, Lock=0x02, Ctrl=0x04, Mod1=Alt=0x08, Mod2=0x10, Mod3=0x20, Mod4=0x40, Mod5=0x80). These names should not be confused with the keys whose pressing might produce the modifier; on US keyboards, keysym Alt_L (keycode 64) and keysym Alt_R (keycode 108) both produce the Alt modifier.

The binding specifications here mostly overlap with those from i3 (see https://i3wm.org/docs/userguide.html#keybindings).

How to identify keys

If you have xev available, run xev -event keyboard to find the translated keysyms and keycodes corresponding to a given key press or release.

A list of keysym names can be found in the xkbcommon-keysyms.h header file, usually located in /usr/include/xkbcommon/.

On Linux, scancode ids are often available in the linux/input-event-codes.h header; the xkb keycodes are typically scancode + 8.

Examples

# These two shortcuts are equivalent
bindsym Ctrl+Shift+1 restart
bindsym Ctrl+exclam restart

# As are these
bindsym Ctrl+q+p exit
bindsym Ctrl+p+q exit

# When the <ESC> key is pressed, switch to workspace "F"
bindcode 9 workspace F

# When the right shift key is released, run the program `false`
bindcode --release Shift_R exec false

# When all modifiers but Caps Lock are active, and keys A
# through G, 1 through 5 are pressed simultaneously, exit
bindsym Mod5+Mod4+Mod3+Mod2+Mod1+Shift+Ctrl+a+b+c+d+e+f+g+1+2+3+4+5 exit

Caveats

Pressing multiple keys which would result in the same modifier change if pressed alone (such as Shift_L and Shift_R on US keyboards) may trigger bindings like bindsym Shift+Shift_R, possibly contrary to expectation.