wms/wms_backgroundize.sh

60 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
2024-01-21 04:05:04 +01:00
# focused window.
FW=$(pfw)
# root window id.
RID=$(lsw -r)
# background window id.
BID=$(lsw -o)
# root width.
RW=$(wattr w $RID)
# root height.
RH=$(wattr h $RID)
# usable screen width.
SW=$((RW - 2 * BW))
# usable screen height.
SH=$((RH - 2 * BW))
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() {
2024-01-21 04:05:04 +01:00
# store size and place of the focused widnow in atom.
atomx WM_IGN="$(wattr xywh $FW) $FW" $FW
# put it on bottom in window stack order.
chwso -l $FW
# make fullsize.
wtp 0 0 $SW $SH $FW
# ignore focused window.
ignw -s $FW
# change border color to BC.
chwb -c $BC $FW
# focus prev window.
wms_mainrole.sh -p
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() {
2024-01-21 04:05:04 +01:00
# unignore.
ignw -r $BID
# restore size an d place.
wtp $(atomx WM_IGN $BID)
# put it on top in the window stack order.
chwso -r $BID
# delete atom.
atomx -d WM_IGN $BID
# focus it.
wms_mainrole.sh $BID
2023-03-09 05:41:12 +01:00
}
2023-03-31 03:21:59 +02:00
if [ -n "$BID" ]; then
restore
else
background
fi