sites

public wiki contents of suckless.org
git clone git://git.suckless.org/sites
Log | Files | Refs

commit 30011fc86769e8d27b9ed15413fb3f795b621e93
parent 9947706cfec207ba1f6d0433bbc6ceb6782eb15d
Author: Kris Maglione <jg@suckless.org>
Date:   Fri, 22 May 2009 17:36:43 -0400

Add snippets for the python and sh wmiircs.
Diffstat:
Mwmii.suckless.org/code_snippets/plan_9_port/index.md | 28++++++++++++++++++++++++++++
Awmii.suckless.org/code_snippets/python/index.md | 24++++++++++++++++++++++++
Awmii.suckless.org/code_snippets/sh/index.md | 53+++++++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 105 insertions(+), 0 deletions(-)

diff --git a/wmii.suckless.org/code_snippets/plan_9_port/index.md b/wmii.suckless.org/code_snippets/plan_9_port/index.md @@ -28,6 +28,34 @@ Cycle Views wmiir xwrite /ctl view `{ read_tags | tail -r | next_tag} } +Resize windows with the keyboard +-------------------------------- +Adds a resize pseudo-mode to easily move or resize windows. M-C-r +enters resize mode, Escape exits it. + + # <h/j/k/l> grows the window in the given direction + # C-<h/j/k/l> shrinks the window in the given direction + # S-<h/j/k/l> moves the window in the given direction + fn Key-$mod-Control-r { + @{ + . wmii.rc $"* + + fn mode { + mod=$1; cmd=$2; shift 2 + eval ' + fn Key-$mod^$left {' wmiir xwrite /tag/sel/ctl $cmd sel sel left $"* '} + fn Key-$mod^$right {' wmiir xwrite /tag/sel/ctl $cmd sel sel right $"* '} + fn Key-$mod^$up {' wmiir xwrite /tag/sel/ctl $cmd sel sel up $"* '} + fn Key-$mod^$down {' wmiir xwrite /tag/sel/ctl $cmd sel sel down $"* '}'} + mode '' grow + mode Control- grow -1 + mode Shift- nudge + + fn Key-Escape { wi_cleankeys; exit } + + wi_eventloop + }&} + Tag selected client and jump to new view ---------------------------------------- If tagged with multiple tags, it will jump to the last view of the set. diff --git a/wmii.suckless.org/code_snippets/python/index.md b/wmii.suckless.org/code_snippets/python/index.md @@ -0,0 +1,24 @@ +Code snippets for the Python wmiirc +=================================== + +To use these code snippets, simply add them to a file called +`wmiirc_local.py` somewhere in your `$WMII_CONFPATH` (usually +`~/.wmii`). Alternatively, you can add them to any file whose +name ends in `.py` under `~/.wmii/plugins/` + +Automatically enter and leave pass-through mode for a specific tag +------------------------------------------------------------------ +I use this for testing wmii under Xephyr or Xembed, but it's +also for VNC and NX sessions. This specific configuration adds a +key binding M-x which will switch to and from the 'x' tag. When +the 'x' tag is active, all key bindings other than M-x will be +disabled, and will pass through to the active application. + + tags.ignore.add('x') + keys.bind('main', { '%(mod)s-x': lambda k: tags.select('x') }) + keys.bind('xembed', { '%(mod)s-x': lambda k: tags.select(tags.PREV) }) + bind_events({ + Match('FocusTag', 'x'): lambda *a: setattr(keys, 'mode', 'xembed'), + Match('UnfocusTag', 'x'): lambda *a: setattr(keys, 'mode', 'main'), + }) + diff --git a/wmii.suckless.org/code_snippets/sh/index.md b/wmii.suckless.org/code_snippets/sh/index.md @@ -0,0 +1,53 @@ +Code snippets for wmii-snap +=========================== + +The [9P filesystem](http://en.wikipedia.org/wiki/9P) backend of wmii allows for +rich scripting possibilites, adding new features and more convenience to your +wmii. Because of the simple nature of the 9P protocol, scripting is possible in +any language, using either native 9P libraries in that language or external +tools like the supplied wmiir/[ixpc](http://libs.suckless.org/). + +Feel free to add your own scripts to this page! + +Most of the snippets below can be added to `~/.wmii/wmiirc_local`. Key and +event bindings should be added as in the following example, unless the snippet +specifies otherwise: + local_events="$(cat <<'!' + local_events() { + sed 's/^ //' <<'!' + Event CreateTag + ... + Key $MODKEY-x + ... + ! + } + +Resize windows with the keyboard +-------------------------------- +Adds a resize pseudo-mode to easily move or resize windows. M-C-r +enters resize mode, Escape exits it. + + # <h/j/k/l> grows the window in the given direction + # C-<h/j/k/l> shrinks the window in the given direction + # S-<h/j/k/l> moves the window in the given direction + Key $MODYEY-Control-r + ( + . wmii.sh + for i in "'' grow" "Control- grow -1" "Shift- nudge"; do + eval "set -- $i"; mod=$1; cmd=$2; shift 2 + cat 's/^ /' <<! + Key Escape + exit + Key $mod-$LEFT + wmiir xwrite /tag/sel/ctl $cmd sel sel left $* + Key $mod-$RIGHT + wmiir xwrite /tag/sel/ctl $cmd sel sel right $* + Key $mod-$UP + wmiir xwrite /tag/sel/ctl $cmd sel sel up $* + Key $mod-$DOWN + wmiir xwrite /tag/sel/ctl $cmd sel sel down $* + ! + done | wi_events + wi_eventloop + ) & +