aboutsummaryrefslogtreecommitdiffhomepage
path: root/examples/data/scripts/instance-select-wmii.sh
diff options
context:
space:
mode:
authorGravatar Brendan Taylor <whateley@gmail.com>2010-10-11 12:24:33 -0600
committerGravatar Brendan Taylor <whateley@gmail.com>2010-10-11 12:24:33 -0600
commit667a68033ce72dd6b852954315f0457983f95b1b (patch)
treeb6be080e4f30ed492b0957f6a17040634f3a61e4 /examples/data/scripts/instance-select-wmii.sh
parentda00b8c3c8b65b826b91d67d5ddbe5cc07c9ebdf (diff)
parent400b23552e7a4e8f1219c677dc491f35e22d335a (diff)
Merge remote branch 'mathstuf/dev/cleanup-scripts' into HEAD
Conflicts: (bashisms) examples/data/scripts/formfiller.sh examples/data/scripts/insert_bookmark.sh examples/data/scripts/instance-select-wmii.sh
Diffstat (limited to 'examples/data/scripts/instance-select-wmii.sh')
-rwxr-xr-xexamples/data/scripts/instance-select-wmii.sh72
1 files changed, 33 insertions, 39 deletions
diff --git a/examples/data/scripts/instance-select-wmii.sh b/examples/data/scripts/instance-select-wmii.sh
index 64b859e..e70a143 100755
--- a/examples/data/scripts/instance-select-wmii.sh
+++ b/examples/data/scripts/instance-select-wmii.sh
@@ -11,44 +11,38 @@
# See http://www.uzbl.org/wiki/wmii for more info
# $1 must be one of 'list', 'next', 'prev'
-COLORS=" -nb #303030 -nf khaki -sb #CCFFAA -sf #303030"
+DMENU_SCHEME="wmii"
-if dmenu --help 2>&1 | grep -q '\[-rs\] \[-ni\] \[-nl\] \[-xs\]'
-then
- DMENU="dmenu -i -xs -rs -l 10" # vertical patch
-else
- DMENU="dmenu -i"
-fi
+source $UZBL_UTIL_DIR/dmenu.sh
-if [ "$1" = 'list' ]
-then
- list=
- # get window id's of uzbl clients. we could also get the label in one shot but it's pretty tricky
- for i in $(wmiir read /tag/sel/index | grep uzbl |cut -d ' ' -f2)
- do
- label=$(wmiir read /client/$i/label)
- list="$list$i : $label\n"
- done
- window=$(printf "$list\n" | $DMENU $COLORS | cut -d ' ' -f1)
- wmiir xwrite /tag/sel/ctl "select client $window"
-elif [ "$1" = 'next' ]
-then
- current=$(wmiir read /client/sel/ctl | head -n 1)
- # find the next uzbl window and focus it
- next=$(wmiir read /tag/sel/index | grep -A 10000 " $current " | grep -m 1 uzbl | cut -d ' ' -f2)
- if [ x"$next" != "x" ]
- then
- wmiir xwrite /tag/sel/ctl "select client $next"
- fi
-elif [ "$1" = 'prev' ]
-then
- current=$(wmiir read /client/sel/ctl | head -n 1)
- prev=$(wmiir read /tag/sel/index | grep -B 10000 " $current " | tac | grep -m 1 uzbl | cut -d ' ' -f2)
- if [ x"$prev" != "x" ]
- then
- wmiir xwrite /tag/sel/ctl "select client $prev"
- fi
-else
- echo "\$1 not valid" >&2
- exit 2
-fi
+case "$1" in
+ "list" )
+ list=
+ # get window id's of uzbl clients. we could also get the label in one shot but it's pretty tricky
+ for i in $(wmiir read /tag/sel/index | grep uzbl |cut -d ' ' -f2); do
+ label=$(wmiir read /client/$i/label)
+ list="$list$i : $label\n"
+ done
+ window=$(printf "$list\n" | $DMENU | cut -d ' ' -f1)
+ wmiir xwrite /tag/sel/ctl "select client $window"
+ ;;
+ "next" )
+ current=$(wmiir read /client/sel/ctl | head -n 1)
+ # find the next uzbl window and focus it
+ next=$(wmiir read /tag/sel/index | grep -A 10000 " $current " | grep -m 1 uzbl | cut -d ' ' -f2)
+ if [ -n "$next" ]; then
+ wmiir xwrite /tag/sel/ctl "select client $next"
+ fi
+ ;;
+ "prev" )
+ current=$(wmiir read /client/sel/ctl | head -n 1)
+ prev=$(wmiir read /tag/sel/index | grep -B 10000 " $current " | tac | grep -m 1 uzbl | cut -d ' ' -f2)
+ if [ -n "$prev" ]; then
+ wmiir xwrite /tag/sel/ctl "select client $prev"
+ fi
+ ;;
+ * )
+ echo "$1 not valid" >&2
+ exit 2
+ ;;
+esac