wms/wms_backgroundize.sh
2023-10-28 00:03:51 -03:00

42 lines
1.1 KiB
Bash
Executable file

#!/bin/sh
## send windows to desktop background ##
## it depends of wms_mainrole.sh ##
. /tmp/wms_var
FLAG=$1
FW=$(pfw) # focused window
RID=$(lsw -r) # root widnow id
BID=$(lsw -o) # bachground window id
RW=$(wattr w $RID) # root width
RH=$(wattr h $RID) # root height
SW=$((RW - 2 * BW)) # usable screen width
SH=$((RH - 2 * BW)) # usable screen height
# send windows to background
background() {
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
chwb -c $BC $FW # change border color to ignore
wms_mainrole.sh -p # focus prev window
}
# restore windows from background
restore() {
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
}
if [ -n "$BID" ]; then
restore
else
background
fi