[hackers] [sites] Add snippets for the python and sh wmiircs. || Kris Maglione

From: <hg_AT_suckless.org>
Date: Sun, 16 Aug 2009 10:54:08 +0000 (UTC)

changeset: 101:0d0fbd22bb46
user: Kris Maglione <jg_AT_suckless.org>
date: Fri May 22 17:36:43 2009 -0400
files: wmii.suckless.org/code_snippets/plan_9_port/index.md wmii.suckless.org/code_snippets/python/index.md wmii.suckless.org/code_snippets/sh/index.md
description:
Add snippets for the python and sh wmiircs.

diff -r c11d6042a507 -r 0d0fbd22bb46 wmii.suckless.org/code_snippets/plan_9_port/index.md
--- a/wmii.suckless.org/code_snippets/plan_9_port/index.md Fri May 22 09:57:39 2009 -0700
+++ b/wmii.suckless.org/code_snippets/plan_9_port/index.md Fri May 22 17:36:43 2009 -0400
@@ -28,6 +28,34 @@
             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 -r c11d6042a507 -r 0d0fbd22bb46 wmii.suckless.org/code_snippets/python/index.md
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/wmii.suckless.org/code_snippets/python/index.md Fri May 22 17:36:43 2009 -0400
@@ -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 -r c11d6042a507 -r 0d0fbd22bb46 wmii.suckless.org/code_snippets/sh/index.md
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/wmii.suckless.org/code_snippets/sh/index.md Fri May 22 17:36:43 2009 -0400
@@ -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
+ ) &
+
Received on Sun Aug 16 2009 - 10:54:08 UTC

This archive was generated by hypermail 2.2.0 : Sun Aug 16 2009 - 14:19:41 UTC