#!/bin/sh ## send windows to desktop background ## . $HOME/.config/wms/wms_var FLAG=$1 FW=$(pfw) # focused window RID=$(lsw -r) # root widnow 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 usage() { echo "usage: wms_backgroundize.sh [ -b, -r ] -b) backgroundize focused window -r) open menu and choose the window/s to restore" } # send windows to background background() { if [ ! "$(wattr o $FW && echo 1)" ]; then # if override is not set wtp 0 0 $SW $SH $FW ignw -s $FW # ignore focused window chwb -c 000000 $FW # change border color to ignore else ignw -r $FW # unignore focused window chwb -c $FG $FW # change border color to active fi } # restore windows from background restore() { if [ -n "$(lsw -o)" ]; then otarget=$(for wid in $(lsw -o); do # override target printf '%s\n' "$wid | $(atomx WM_CLASS $wid) | $(wname $wid)" done | cut -c 1-100 | $XMENU | cut -d ' ' -f 1) ignw -r $otarget # unignore otarget fi } case $FLAG in -b) background ;; -r) restore ;; *) usage ;; esac