wms/wms_focuser.sh

70 lines
1,009 B
Bash
Raw Normal View History

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