Project

General

Profile

unexist.dev

subtle

Assorted tidbits and projects

Grabs » History » Version 52

Anonymous, 01/29/2011 06:26 PM

1 52
h1. Grabs\015\012\015\012{{>toc}}\015\012\015\012[[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.\015\012\015\012Genereally there are different types of [[grabs]]:\015\012# Predefined [[grabs]] that call a specific actions\015\012# [[Grabs]] that call a "Ruby":http://www.ruby-lang.org block\015\012# [[Grabs]] that exec a program\015\012\015\012h2. Finding keys\015\012\015\012The 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:\015\012\015\012* Numbers and letters keep their names, so *a* is *a* and *0* is *0*\015\012* Keypad keys need *KP_* as prefix, so *KP_1* is *1* on the keypad\015\012* Strip the *XK_* from the key names if looked up in @/usr/include/X11/keysymdef.h@\015\012* Keys usually have meaningful english names\015\012* Modifier keys have special meaning (Alt (*A*), Control (*C*), Meta (*M*), Shift (*S*), Super (*W*))\015\012\015\012h3. Chaining\015\012\015\012Chains 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:\015\012\015\012# *Default*: Add modifiers to a key and use it for a [[grabs|grab]]\015\012\015\012  *Example*: @grab "W-Return", "urxvt"@\015\012# *Chain*: Define a list of [[grabs]] that need to be pressed:\015\012\015\012  *Example*: @grab "C-y Return", "urxvt"@\015\012\015\012h3. Mouse buttons\015\012\015\012* *B1* = Button1 (Left mouse button)\015\012* *B2* = Button2 (Middle mouse button)\015\012* *B3* = Button3 (Right mouse button)\015\012* *B4* = Button4 (Mouse wheel up)\015\012* *B5* = Button5 (Mouse wheel down)\015\012\015\012h3. Modifier keys\015\012\015\012* *A* = Alt key\015\012* *C* = Control key\015\012* *M* = Meta key\015\012* *S* = Shift key\015\012* *W* = Super (Windows key)\015\012\015\012h3. Common keys\015\012\015\012* *Space*\015\012* *Tab*\015\012* *Enter* / *Return*\015\012* *F1* - *F12*\015\012* *Left*, *Down*, *Up*, *Right*\015\012* *Next*, *Prior*\015\012* *Page_Up*, *Page_Down*\015\012* *Home*, *End*\015\012* *Insert*, *Delete*\015\012* *Add*, *Subtract*, *Multiply*, *Divide*, *Equal*\015\012* *Decimal*\015\012* *Num_Lock*\015\012* *Escape*\015\012\015\012h3. Multimedia keys\015\012\015\012The following list shows some typically used keynames for multimedia keys. Per default they are unassigned, see [[Grabs#Assigning-keynames|Assigning keynames]] for more.\015\012\015\012* *XF86AudioMute*\015\012* *XF86AudioRaiseVolume*\015\012* *XF86AudioLowerVolume*\015\012* *XF86AudioPlay*\015\012* *XF86AudioPrev*\015\012* *XF86AudioNext*\015\012* *XF86WWW*\015\012* *XF86Calculator*\015\012* *XF86Mail*\015\012\015\012The complete list with all keynames can be found in @/usr/share/X11/XKeysymDB@.\015\012\015\012If 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.\015\012 \015\012<pre><code class="ruby">\015\012# Multimedia Keys\015\012grab "XF86AudioPlay", "ncmpcpp toggle"\015\012grab "XF86AudioNext", "ncmpcpp next"\015\012grab "XF86AudioPrev", "ncmpcpp prev"\015\012grab "XF86AudioStop", "ncmpcpp stop"\015\012</code></pre> \015\012\015\012h3. Fn keys\015\012\015\012Fn keys found on notebooks other than numpad keys can't be used directly, they need to be defined. See [[Grabs#Assigning-keynames|Assigning keynames]] for more.\015\012\015\012h3. Examples\015\012\015\012<pre>{{hide}}<code class="ruby">\015\012grab "S-B1", :WindowMove\015\012grab "A-space" do |c|\015\012  c.toggle_float\015\012end\015\012grab "W-F1", "xterm -sb"\015\012</code></pre>\015\012\015\012h2. Assigning keynames\015\012\015\012Keys like the multimedia keys are unassigned or even unknown to the xserver and can't be used directly, but "xmodmap":http://www.linuxmanpages.com/man1/xmodmap.1x.php can be used to assign keynames to these new keycodes. To get the actual keycodes of a key there is "showkey":http://www.linuxmanpages.com/man1/showkey.1.php, a tool that can't be used in a virtual terminal.\015\012\015\012* Get keycode\015\012\015\012<pre><code class="bash">\015\012kb mode was XLATE\015\012\015\012press any key (program terminates 10s after last keypress)...\015\012keycode  28 release\015\012keycode 153 press\015\012keycode 153 release\015\012</code></pre>\015\012\015\012* Add to _~/.Xmodmap_\015\012\015\012<pre><code class="bash">\015\012keycode 153 = XF86AudioNext\015\012</code></pre>\015\012\015\012* Add grab to [[subtle]] config\015\012\015\012<pre><code class="ruby">\015\012 grab "XF86AudioNext", "mpc next"\015\012</code></pre>\015\012\015\012h2. Predefined\015\012\015\012h3. Escape\015\012\015\012Set an escape [[grabs|grab]] that needs to be pressed before *any* other [[grabs|grab]] can be used like in "screen":http://www.gnu.org/software/screen//"tmux":http://tmux.sourceforge.net/.\015\012\015\012h3. Subtle\015\012\015\012h4. SubtleReload\015\012\015\012Reload config and [[sublets]].\015\012\015\012Example:\015\012\015\012<pre><code class="ruby">grab "W-C-r", :SubtleReload</code></pre>\015\012\015\012h4. SubtleRestart\015\012\015\012Restart subtle without exiting "Xorg":http://www.x.org/wiki/.\015\012\015\012Example:\015\012\015\012<pre><code class="ruby">grab "W-C-S-r", :SubtleRestart</code></pre>\015\012\015\012h4. SubtleQuit\015\012\015\012Quit [[subtle]] and exit" Xorg":http://www.x.org/wiki/ session.\015\012\015\012Example:\015\012\015\012<pre><code class="ruby">grab "W-C-q", :SubtleQuit</code></pre>\015\012\015\012h3. Views\015\012\015\012h4. ViewJump\015\012\015\012Move pointer either to screen showing numbered view (_multihead_) or open numbered view on current screen.\015\012\015\012* *ViewJump1*\015\012* *ViewJump2*\015\012* *...*\015\012* *ViewJumpN*\015\012\015\012Example:\015\012\015\012<pre><code class="ruby">grab "W-S-1", :ViewJump1</code></pre>\015\012\015\012h4. ViewSwitch\015\012\015\012Set current view to numbered view and swap view with screen currently showing it. (_multihead_)\015\012\015\012* *ViewSwitch1*\015\012* *ViewSwitch2*\015\012* *...*\015\012* *ViewSwitchN*\015\012\015\012Example:\015\012\015\012<pre><code class="ruby">grab "W-1", :ViewSwitch</code></pre>\015\012\015\012h4. ViewNext\015\012\015\012Select next view.\015\012\015\012Example:\015\012\015\012<pre><code class="ruby">grab "KP_Add", :ViewNext</code></pre>\015\012\015\012h4. ViewPrev\015\012\015\012Select previous view.\015\012\015\012Example:\015\012\015\012<pre><code class="ruby">grab "KP_Subtract", :ViewPrev</code></pre>\015\012\015\012h3. Screens\015\012\015\012h4. ScreenJump\015\012\015\012Move pointer to the numbered screen.\015\012\015\012* *ScreenJump1*\015\012* *ScreenJump2*\015\012* *..*\015\012* *ScreenJumpN*\015\012\015\012Example:\015\012\015\012<pre><code class="ruby">grab "W-A-1", :ScreenJump1</code></pre>\015\012\015\012h3. Windows\015\012\015\012Window [[grabs]] manipulate/toggle various properties of client windows.\015\012\015\012h4. WindowMove\015\012\015\012Move 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. \015\012\015\012Example:\015\012\015\012<pre><code class="ruby">grab "W-B1", :WindowMove</code></pre>\015\012\015\012h4. WindowResize\015\012\015\012Resize 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. \015\012\015\012Example:\015\012\015\012<pre><code class="ruby">grab "W-B3", :WindowResize</code></pre>\015\012\015\012h4. WindowFloat\015\012\015\012Toggle floating mode of window. Floating windows have no gravity and _float_ above the other windows.\015\012\015\012Example:\015\012\015\012<pre><code class="ruby">grab "W-f", :WindowFloat</code></pre>\015\012\015\012h4. WindowFull\015\012\015\012Toggle fullscreen mode of window.\015\012\015\012Example:\015\012\015\012<pre><code class="ruby">grab "W-space", :WindowFull</code></pre>\015\012\015\012h4. WindowStick\015\012\015\012Toggle sticky mode of window. Sticky windows appear on all screens.\015\012\015\012Example:\015\012\015\012<pre><code class="ruby">grab "W-s", :WindowStick</code></pre>\015\012\015\012h4. WindowRaise\015\012\015\012Move window to top of window stacking list.\015\012\015\012Example:\015\012\015\012<pre><code class="ruby">grab "W-r", :WindowRaise</code></pre>\015\012\015\012h4. WindowLower\015\012\015\012Move window to bottom of window stacking list.\015\012\015\012\015\012Example:\015\012\015\012<pre><code class="ruby">grab "W-l", :WindowLower</code></pre>\015\012\015\012h4. WindowLeft\015\012\015\012Select window left of current window.\015\012\015\012Example:\015\012\015\012<pre><code class="ruby">grab "W-Left", :WindowLeft</code></pre>\015\012\015\012h4. WindowDown\015\012\015\012Select window below current window.\015\012\015\012Example:\015\012\015\012<pre><code class="ruby">grab "W-Down", :WindowDown</code></pre>\015\012\015\012h4. WindowUp\015\012\015\012Select window above current window.\015\012\015\012Example:\015\012\015\012<pre><code class="ruby">grab "W-Up", :WindowUp</code></pre>\015\012\015\012h4. WindowRight\015\012\015\012Select window right of current window.\015\012\015\012Example:\015\012\015\012<pre><code class="ruby">grab "W-Right", :WindowRight</code></pre>\015\012\015\012h4. WindowKill\015\012\015\012Kill current window.\015\012\015\012Example:\015\012\015\012<pre><code class="ruby">grab "W-k", :WindowKill</code></pre>\015\012\015\012h3. Gravities\015\012\015\012[[Gravity]] [[grabs]] change the [[gravity]] of the selected client on the current view, they are basically a list of [[Gravity|gravities]] and are toggled.\015\012\015\012Example:\015\012\015\012<pre><code class="ruby">grab "W-KP_7", [ :top_left, :top_left66, :top_left33 ]</code></pre>\015\012\015\012h2. Blocks\015\012\015\012[[Grabs]] can also call a "Ruby":http://www.ruby-lang.org 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_.\015\012\015\012Example:\015\012\015\012<pre>{{hide}}<code class="ruby">\015\012grab "S-F2" do |c| \015\012  puts c.name\015\012end\015\012</code></pre>\015\012\015\012h2. Exec\015\012\015\012Invoke a shell and exec a program.\015\012\015\012Example:\015\012\015\012<pre><code class="ruby">grab "W-Return", "urxvt"</code></pre>