wms/wms_backgroundize.sh

42 lines
1.1 KiB
Bash
Raw Normal View History

2023-03-07 02:55:30 +01:00
#!/bin/sh
2023-03-07 14:01:29 +01:00
## send windows to desktop background ##
2023-03-31 15:44:07 +02:00
## it depends of wms_mainrole.sh ##
2023-03-07 14:01:29 +01:00
2023-08-08 04:42:24 +02:00
. /tmp/wms_var
2023-03-07 02:55:30 +01:00
FLAG=$1
2023-03-07 14:01:29 +01:00
FW=$(pfw) # focused window
RID=$(lsw -r) # root widnow id
2023-03-31 03:21:59 +02:00
BID=$(lsw -o) # bachground window id
2023-03-07 14:01:29 +01:00
RW=$(wattr w $RID) # root width
RH=$(wattr h $RID) # root height
2023-10-28 05:03:51 +02:00
SW=$((RW - 2 * BW)) # usable screen width
SH=$((RH - 2 * BW)) # usable screen height
2023-03-07 02:55:30 +01:00
2023-03-09 05:41:12 +01:00
# send windows to background
2023-03-14 04:51:11 +01:00
background() {
2023-03-31 03:21:59 +02:00
atomx WM_IGN="$(wattr xywh $FW) $FW" $FW # store size and place in atom
chwso -l $FW # put on bottom in window stack order
wtp 0 0 $SW $SH $FW # fullsize
ignw -s $FW # ignore focused window
2023-10-28 05:03:51 +02:00
chwb -c $BC $FW # change border color to ignore
2023-03-31 03:21:59 +02:00
wms_mainrole.sh -p # focus prev window
2023-03-09 05:41:12 +01:00
}
2023-03-07 02:55:30 +01:00
2023-03-09 05:41:12 +01:00
# restore windows from background
2023-03-14 04:51:11 +01:00
restore() {
2023-03-31 03:21:59 +02:00
ignw -r $BID # unignore
wtp $(atomx WM_IGN $BID) # restore size and place
chwso -r $BID # put on top in the window stack order
atomx -d WM_IGN $BID # delete atom
wms_mainrole.sh $BID # focus
2023-03-09 05:41:12 +01:00
}
2023-03-31 03:21:59 +02:00
if [ -n "$BID" ]; then
restore
else
background
fi