aboutsummaryrefslogtreecommitdiffhomepage
path: root/examples/data/scripts/instance-select-wmii.sh
diff options
context:
space:
mode:
authorGravatar Ben Boeckel <MathStuf@gmail.com>2010-08-21 12:02:43 -0400
committerGravatar Ben Boeckel <MathStuf@gmail.com>2010-10-02 11:56:30 -0400
commitcfd3ff8fcff8aad7b57d8b757c2401f58aebd561 (patch)
tree08a8ecfe305bcbfc8e60602c3f49a125a8bf4dce /examples/data/scripts/instance-select-wmii.sh
parente0e443e5c5bbd7663542788401d0e44da91e301e (diff)
Use a case statement in the wmii script
Diffstat (limited to 'examples/data/scripts/instance-select-wmii.sh')
-rwxr-xr-xexamples/data/scripts/instance-select-wmii.sh57
1 files changed, 31 insertions, 26 deletions
diff --git a/examples/data/scripts/instance-select-wmii.sh b/examples/data/scripts/instance-select-wmii.sh
index dcb8866..1fc6ed0 100755
--- a/examples/data/scripts/instance-select-wmii.sh
+++ b/examples/data/scripts/instance-select-wmii.sh
@@ -13,29 +13,34 @@
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=$(echo -e "$list" | $DMENU | 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 [ -n "$next" ]; 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 [ -n "$prev" ]; 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=$(echo -e "$list" | $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