- Finding keys
- Assigning keynames
Grabs are the mouse button/keyboard mappings in subtle and can be used in various combinations, no grab is limited either to button or keyboard only. Generally they are combinations or chains of one or more modifiers and a button/key.Genereally there are different types of grabs:
- Predefined grabs that call a specific actions
- Grabs that call a Ruby block
- Grabs that exec a program
The best resource for getting the correct key names is
/usr/include/X11/keysymdef.h, but to make life easier here are some hints about it:
- Numbers and letters keep their names, so a is a and 0 is 0
- Keypad keys need KP_ as prefix, so KP_1 is 1 on the keypad
- Strip the XK_ from the key names if looked up in
- Keys usually have meaningful english names
- Modifier keys have special meaning (Alt (A), Control (C), Meta (M), Shift (S), Super (W), AltGr (G))
Chains are a combination of keys and modifiers to one or a list of keys and can be used in various ways to trigger an action. In subtle, there are two ways to define chains for grabs:
- Default: Add modifiers to a key and use it for a grab
grab "W-Return", "urxvt"
- Chain: Define a list of grabs that need to be pressed:
grab "C-y Return", "urxvt"
- B1 = Button1 (Left mouse button)
- B2 = Button2 (Middle mouse button)
- B3 = Button3 (Right mouse button)
- B4 = Button4 (Mouse wheel up)
- B5 = Button5 (Mouse wheel down)
- B20 = Button20 (Are you sure that this is a mouse and not a keyboard?)
- A = Alt key (Mod1)
- C = Control key
- M = Meta key (Mod3)
- S = Shift key
- W = Super/Windows key (Mod4)
- G = AltGr key (Mod5) (since r3004)
- Enter / Return
- F1 - F12
- Left, Down, Up, Right
- Next, Prior
- Page_Up, Page_Down
- Home, End
- Insert, Delete
- Add, Subtract, Multiply, Divide, Equal
The following list shows some typically used keynames for multimedia keys. Per default they are unassigned, see Assigning keynames for more.
The complete list with all keynames can be found in
If you use ncmpcpp for your music player needs, you can use your multimedia keys to control playback. Simply copy the below code into your config.
1 # Multimedia Keys 2 grab "XF86AudioPlay", "ncmpcpp toggle" 3 grab "XF86AudioNext", "ncmpcpp next" 4 grab "XF86AudioPrev", "ncmpcpp prev" 5 grab "XF86AudioStop", "ncmpcpp stop"
Fn keys found on notebooks other than numpad keys can't be used directly, they need to be defined. See Assigning keynames for more.
Numbers: on /off
1 grab "S-B1", :WindowMove 2 grab "A-space" do |c| 3 c.toggle_float 4 end 5 grab "W-F1", "xterm -sb"
Keys like the multimedia keys are unassigned or even unknown to the xserver and can't be used directly, but xmodmap can be used to assign keynames to these new keycodes. To get the actual keycodes of a key there is showkey, a tool that can't be used in a virtual terminal.
- Get keycode
1 kb mode was XLATE 2 3 press any key (program terminates 10s after last keypress)... 4 keycode 28 release 5 keycode 153 press 6 keycode 153 release
- Add to ~/.Xmodmap
1 keycode 153 = XF86AudioNext
- Add grab to subtle config
1 grab "XF86AudioNext", "mpc next"
Reload config and sublets.
1 grab "W-C-r", :SubtleReload
Restart subtle without exiting Xorg.
1 grab "W-C-S-r", :SubtleRestart
1 grab "W-C-q", :SubtleQuit
Move pointer either to screen showing numbered view (multihead) or open numbered view on current screen.
1 grab "W-S-1", :ViewJump1
Set current view to numbered view and swap view with screen currently showing it. (multihead)
1 grab "W-1", :ViewSwitch
Select next view.
1 grab "KP_Add", :ViewNext
Select previous view.
1 grab "KP_Subtract", :ViewPrev
Move pointer to the numbered screen.
1 grab "W-A-1", :ScreenJump1
Move window either by mouse movement while holding the mouse button or via arrow/cursor keys. The move mode can be exited either with releasing the mouse button or pressing return.
1 grab "W-B1", :WindowMove
Move window to selected direction pixel steps defined by the :step option.
1 grab "W-Up", :WindowMoveUp 2 grab "W-Right", :WindowMoveUp 3 grab "W-Down", :WindowMoveUp 4 grab "W-Left", :WindowMoveUp
Resize window either by mouse movement while holding the mouse button or via arrow/cursor keys. The resize mode can be exited either with releasing the mouse button or pressing return.
1 grab "W-B3", :WindowResize
Resize window in selected direction pixel steps defined by the :step option.
1 grab "W-Up", :WindowResizeUp 2 grab "W-Right", :WindowResizeUp 3 grab "W-Down", :WindowResizeUp 4 grab "W-Left", :WindowResizeUp
1 grab "W-f", :WindowFloat
Toggle [[Clients|Fullscreen|fullscreen]] mode of window.
1 grab "W-space", :WindowFull
1 grab "W-s", :WindowStick
1 grab "W-s", :WindowStick
Move window to top of window stacking list.
1 grab "W-r", :WindowRaise
Move window to bottom of window stacking list.
1 grab "W-l", :WindowLower
1 grab "W-Up", :WindowUp 2 grab "W-Right", :WindowRight 3 grab "W-Down", :WindowDown 4 grab "W-Left", :WindowLeft
Kill current window.
1 grab "W-k", :WindowKill
1 grab "W-KP_7", [ :top_left, :top_left66, :top_left33 ]
Grabs can also call a Ruby block (aka lambda/proc), the arity of the block is either a client window or none. Inside of the blocks the whole API of subtlext can be used, the extension will be loaded ondemand.
Invoke a shell and exec a program.
1 grab "W-Return", "urxvt"