master hovercats/bin / rc / focus
 1#!/bin/rc
 2
 3flag e +
 4
 5switch($1) {
 6	case next 
 7		wid=`{lsw | grep -v `{pfw} | sed '1 p;d'}
 8	case prev 
 9		wid=`{lsw | grep -v `{pfw} | sed '$ p;d'}
10	case top  
11		wid=`{lsw | sed '$ p;d'}
12	case 0x*  
13		wattr $1 && wid=$1
14	case *    
15		printf 'Usage: next|prev|top|wid\n'
16		exit 1
17}
18
19# exit if we can't find another window to focus
20if (~ $#wid 0) printf 'No window to focus on\n' && exit 0
21
22chwso -r $wid # put it on top of the stack
23wtf      $wid # set focus on it