[wiki] [upstream] Update wmii code snippets || Kris Maglione

From: <hg_AT_suckless.org>
Date: Mon, 15 Dec 2008 07:51:22 +0000 (GMT)

changeset: 195:88a9dbbc4d06
tag: tip
user: Kris Maglione <jg_AT_suckless.org>
date: Mon Dec 15 02:30:44 2008 -0500
files: wmii/scripts_n_snips/code_snippets.md
description:
Update wmii code snippets


diff -r 9f369fa1ed64 -r 88a9dbbc4d06 wmii/scripts_n_snips/code_snippets.md
--- a/wmii/scripts_n_snips/code_snippets.md Sat Dec 13 08:26:53 2008 +0900
+++ b/wmii/scripts_n_snips/code_snippets.md Mon Dec 15 02:30:44 2008 -0500
_AT_@ -18,7 +18,7 @@
 Cycle Views
 -----------
     fn next_tag {
- awk -v curtag'='`{wmiir read /tag/sel/ctl | head -n 1} '
+ awk -v curtag'='`{wmiir read /tag/sel/ctl | sed 1q} '
                 NR==1 {first = $0}
                 $0==curtag { if(getline) print $0; else print first; exit }'
     }
_AT_@ -34,9 +34,9 @@
 If tagged with multiple tags, it will jump to the last view of the set.
 
     fn Key-MODKEY-Control-t {
- newtag=`{read_tags | wmiimenu}
+ newtag=`{wi_tags | wi_menu}
             wmiir xwrite /client/sel/tags $newtag
- newtag=`{echo $newtag | sed 's/.*\+//'}
+ newtag=`{echo $newtag | sed 's/.*\+//; s/-.*//'}
             wmiir xwrite /ctl view $newtag
     }
 
_AT_@ -64,59 +64,57 @@
 Tag addition and subtraction using tag+ and tag-
 ------------------------------------------------
 
-If you tend to rely on dmenu's completion for retagging, it can be annoying that + or - prefix
+If you tend to rely on wimenu's completion for retagging, it can be annoying that + or - prefix
 renders it useless. This snippet allows you to append the + or -, rather than prepending
 it. Prepending still works as before.
 
     fn Key-$MODKEY-Shift-t {
- tag=`{read_tags | wmiimenu | sed 's/(.*)([+\-])$/\2\1/'}
- wmiir xwrite /client/`{wmiir read /client/sel/ctl}^/tags $tag
+ tag=`{wi_tags | wimenu | sed 's/(.*)([+\-])$/\2\1/'}
+ wmiir xwrite /client/`{wmiir read /client/sel/ctl | sed 1q}^/tags $tag
     }
 
 Retag all clients in a view
 ---------------------------
     fn clients_on {
- wmiir read /tag/$1/index | sed -e '/^#/d' -e 's,.*\(0x[^ ]*\).*,\1,'
+ wmiir read /tag/$1/index | awk '!/^#/ { print $2 }'
     }
 
     fn Key-$MODKEY-r {
- target=`{read_tags | wmiimenu}
+ target=`{wi_tags | wimenu}
             for(c in `{clients_on sel}){
- wmiir xwrite /client/$c/tags $target
+ wmiir xwrite /client/$c/tags -sel+$target
             }
- wmiir xwrite /ctl view $ctag
+ wmiir xwrite /ctl view $target
     }
 
 Cycle trough tags starting with a specific character
 ----------------------------------------------------
 
-(No troughoutly tested, but should work)
+(No tested, but might work)
 Add a event in wmiirc that calls the following code.
 If you have 3 tags named plan9, planner and plant: by calling the script you will cycle between the 3.
 (Note: it does not work with capitals)
 
       count=1
       fn TagCycle {
- inputtag=`{echo $1 | tail -c 2}
- currenttag=`{wmiir read /ctl | sed -n '1p' | awk '{ print $2 }' | head -c 1}
- if(~ $currenttag $inputtag ) {
+ inputtag=$1
+ currenttag=`{wmiir read /tag/sel/ctl | awk '{ print substr($2, 1, 1); exit }'}
+ if(~ $currenttag $inputtag) {
               count=`{expr $count + 1}
- maxcount=`{wmiir ls /lbar | grep '^'$inputtag | wc -l}
- maxcount=`{expr $maxcount + 1}
- if (~ $count $maxcount ){
+ maxcount=`{wi_tags | grep '^'$inputtag | wc -l}
+ if (test $count -gt $maxcount)
+ count=1
+ }
+ if not
               count=1
- }
- }
- if not{
- count=1
- }
- gototag=`{wmiir ls /lbar | grep '^'$inputtag | sed -n $count^p}
+ gototag=`{wi_tags | grep '^'$inputtag | sed -n $count^p}
           wmiir xwrite /ctl view $gototag
       }
 
 To easily add the entire alphabet in the bound buttons you can use this code.
-Add this to your rc.wmi BEFORE the other keys (you still want your other old keys to work right ?):
+Add this to your rc.wmii BEFORE the other keys (you still want your other old keys to work right ?):
 
       # Tag cycle
- key $MODKEYA-^`{echo a b c d e f g h i j k l m n o p q r s t u v w x y z} || fn $key {
- TagCycle ($1)}
+ key $MODKEY-A-^(a b c d e f g h i j k l m n o p q r s t u v w x y z) || fn $key {
+ TagCycle $1}
+
Received on Mon Dec 15 2008 - 08:51:22 CET

This archive was generated by hypermail 2.3.0 : Thu Sep 13 2012 - 19:30:29 CEST