82 lines
1.4 KiB
Bash
Executable file
82 lines
1.4 KiB
Bash
Executable file
#!/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"
|
|
}
|
|
|
|
name() {
|
|
$XMENU < $NAMES
|
|
}
|
|
|
|
# create atom in focused window
|
|
add_focused() {
|
|
if [ -n "name" ]; then
|
|
atomx WM_HERD="$(name)_$FW" $FW
|
|
fi
|
|
}
|
|
|
|
# create atom in all maped windows
|
|
add_all() {
|
|
if [ -n "name" ]; then
|
|
for wid in $(lsw); do
|
|
atomx WM_HERD="$(name)_$wid" $wid
|
|
done
|
|
fi
|
|
}
|
|
|
|
# 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
|
|
map_wind=$(atomx WM_HERD $(lsw -u) | grep $h_target | cut -d '_' -f2) # windows to map
|
|
unmap_wind=$(atomx WM_HERD $(lsw) | grep -v $h_target | cut -d '_' -f2) # windows to unmap
|
|
mapw -m $map_wind & mapw -u $unmap_wind
|
|
fi
|
|
}
|
|
|
|
|
|
case $FLAG in
|
|
-a)
|
|
add_focused
|
|
;;
|
|
-A)
|
|
add_all
|
|
;;
|
|
-d)
|
|
del_focused
|
|
;;
|
|
-D)
|
|
dell_all
|
|
;;
|
|
-t)
|
|
togle
|
|
;;
|
|
*)
|
|
usage # self-explained
|
|
;;
|
|
esac
|