wms/wms_focuser.sh

70 lines
1,009 B
Bash
Raw Normal View History

2023-03-06 15:08:25 -03:00
#!/bin/sh
2023-03-07 10:01:29 -03:00
## give windows the stardom ##
2024-02-22 00:31:42 -03:00
. $HOME/.config/wms/wms_var
2023-03-06 15:08:25 -03:00
2023-03-12 00:54:44 -03:00
FLAG=$1
2024-01-21 00:05:04 -03:00
# focused window.
2023-03-09 16:06:13 -03:00
FW=$(pfw)
2023-03-06 15:08:25 -03:00
usage() {
2023-07-24 03:08:48 -03:00
cat<<EOF
usage:
2023-07-22 11:36:15 -03:00
wms_mainrole.sh [ -n, -p, -t, wid ]
2023-03-06 15:08:25 -03:00
-n) next in order stack
-p) prev in order stack
-t) focus the top window in the servers window stack
2023-07-24 03:08:48 -03:00
wid) window id
EOF
2023-03-06 15:08:25 -03:00
}
2023-10-28 00:03:51 -03:00
# focus next window in server's window stack order
2023-03-09 16:06:13 -03:00
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() {
2023-03-12 00:54:44 -03:00
wattr $FLAG && wid=$FLAG
2023-03-09 16:06:13 -03:00
chwso -r $wid
}
2023-03-12 00:54:44 -03:00
case $FLAG in
2023-03-09 16:06:13 -03:00
-n)
next
2023-03-06 15:08:25 -03:00
;;
2023-03-09 16:06:13 -03:00
-p)
prev
2023-03-06 15:08:25 -03:00
;;
2023-03-09 16:06:13 -03:00
-t)
top
2023-03-06 15:08:25 -03:00
;;
2023-03-09 16:06:13 -03:00
0x*)
on_wid
2023-03-06 15:08:25 -03:00
;;
*)
usage
;;
esac
# transfer focus
wtf $wid
2024-01-21 00:05:04 -03:00
# set colors on the unfocused windows.
2024-02-22 00:31:42 -03:00
chwb -s $BW -c $IC $(lsw | grep -v $wid)
2024-01-21 00:05:04 -03:00
# set colors on the focused widnow.
2024-02-22 00:31:42 -03:00
chwb -s $BW -c $AC $wid