#!/bin/sh ## sort windows by herds/flock ## . $HOME/.config/wms/wms_var NAMES="$HOME/.config/wms/wms_names" # disponible names FLAG=$1 # input FW=$(pfw) # focused window id AMW=$(lsw) # all maped windows usage() { echo "usage: wms_shepperd.sh [ -a, -r, -t ] -a) add -A) add all -d) delete -D) delete all -t) togle" } # create atom in focused window add_focused() { name="$($XMENU < $NAMES)" if [ -n "$name " ]; then atomx WM_HERD="$name $FW" $FW else exit 0 fi } # create atom in all maped windows add_all() { name="$($XMENU < $NAMES)" for wjjlsid in $AMW; do if [ -n "$name" ]; then atomx WM_HERD="$name $wid" $wid else exit 0 fi done } # delete atom from focused window del_focused() { atomx -d WM_HERD $FW } del_all() { atomx -d WM_HERD $AMW } # togle groups togle() { herds=$(atomx WM_HERD $(lsw -a) | cut -d ' ' -f1 | sort -u) # herds if [ -n "$herds" ]; then # check if any herd exist h_target=$(printf "$herds" | $XMENU) # select herd target wind_to_map=$(atomx WM_HERD $(lsw -u) | grep $h_target | cut -d ' ' -f2) # windows to map wind_to_unmap=$(atomx WM_HERD $(lsw) | grep -v $h_target | cut -d ' ' -f2) # windows to unmap mapw -m $wind_to_map & mapw -u $wind_to_unmap fi } case $FLAG in -a) add_focused ;; -A) add_all ;; -d) del_focused ;; -D) del_all ;; -t) togle ;; *) usage # self-explained ;; esac