diff --git a/rwm_mainrole.sh b/rwm_mainrole.sh index fc71dbf..5062a1d 100755 --- a/rwm_mainrole.sh +++ b/rwm_mainrole.sh @@ -4,6 +4,8 @@ . $HOME/.config/rootwm/rwm_var +FW=$(pfw) + usage() { echo "usage: rwm_starship.sh [ -n, -p, -l, wid ] @@ -13,21 +15,41 @@ rwm_starship.sh [ -n, -p, -l, wid ] wid) window id" } +# docus next window in server's window stack order +next() { + wid=$(lsw | grep -v $FW | sed '1 p;d') + chwso -r $wid +} + +# focus previous window in in server's window stack order +prev() { + wid=$(lsw | grep -v $FW | sed '$ p;d') + chwso -r $wid +} + +# focus the top window in the server's window stack order +top() { + wid=$(lsw | sed '$ p;d') +} + +# focus on wid +on_wid() { + wattr $1 && wid=$1 + chwso -r $wid +} + case $1 in - -n) # focus next in stack order - wid=$(lsw | grep -v $(pfw) | sed '1 p;d') - chwso -r $wid + -n) + next ;; - -p) # focus prev in stack order - wid=$(lsw | grep -v $(pfw) | sed '$ p;d') - chwso -r $wid + -p) + prev ;; - -t) # focus the top window in the server’s window stack - wid=$(lsw | sed '$ p;d') + -t) + top ;; - 0x*) # focus on wid - wattr $1 && wid=$1 - chwso -r $wid + 0x*) + on_wid ;; *) usage