[dev] [wmii] Add/Remove all windows with n tag to/from the current view [code snippet plan9]

From: Ruben Gonzalez Arnau <ruben_AT_websbarcelona.com>
Date: Mon, 06 Dec 2010 16:32:20 +0100

Hello,

A simple task to view all windows from ntag to current view. If it's
useful for someone, I will try to put on wiki.

Ex: $MODKEY-Control-[1-9] adds ntga windows, if pressed again, removes
ntag windows.

Any help is appreciated :)

Thank you!

fn getcurtag {
         wmiir read /tag/sel/ctl | sed 1q
}

fn getclientsntag {
         wmiir read /tag/$1/index | awk '/0x[a-fA-F0-9]/ { print $2 }'
}

fn viewntag {
         ntag = $1
         curtag = `{getcurtag}
         cmatch = 0

         if(! ~ $ntag $curtag && ! ~ $#ntag 0) {
                 for(c in `{getclientsntag $ntag}) {
                         for(cc in `{getclientsntag $curtag}) {
                                 if(~ $c $cc)
                                         cmatch = 1
                         }
                         if(test $cmatch -eq 1)
                                 wmiir xwrite /client/$c/tags $ntag-$curtag
                         if not
                                 wmiir xwrite /client/$c/tags $ntag+$curtag
                 }
         }
}

# Switch to named view by number
fn keynum {
         echo `{echo $1 | sed 's/.*-//'}
}
fn tagnum {
         echo `{wi_tags | sed -n $1^p}
}

# Add/Remove all windows with ntag to/from the view
for(i in `{seq 1 9}) {
         fn Key-$MODKEY-Control-$i {
                 viewntag `{tagnum `{keynum $1}}
         }
}
Received on Mon Dec 06 2010 - 16:32:20 CET

This archive was generated by hypermail 2.2.0 : Mon Dec 06 2010 - 16:48:02 CET