zenUtils/rio.sh

70 lines
1.1 KiB
Bash
Executable file

#!/bin/sh
# use slop and wmctrl to emulate rio behavior in an EWMH compliant WM
# Derek Stevens <nilix@nilfm.cc>
# MIT License
termcmd="alacritty --option geometry="
movebind="super+v"
delete()
{
wmctrl -c :SELECT:
}
new()
{
geom=$(slop -t 0 -f %x,%y,%w,%h)
x=$(echo $geom | awk -F , '{print $1}')
y=$(echo $geom | awk -F , '{print $2}')
wl=$(mktemp .windowlistXXX)
wmctrl -l >> $wl
${termcmd}80x24+${x}+${y}&
while true; do
lastCreatedID=$(wmctrl -l | tail -n 1 | awk '{print $1}')
if [ "$lastCreatedID" != "$(tail -n 1 $wl | awk '{print $1}')" ]; then
break
fi
done
wmctrl -i -r $lastCreatedID -e 0,$geom
rm $wl
}
resize()
{
wid=$(slop -t 9999999 -f %i)
geom=$(slop -t 0 -f %x,%y,%w,%h)
wmctrl -i -r $wid -b remove,maximized_vert,maximized_horz
wmctrl -i -r $wid -e 0,$geom
}
move()
{
wid=$(slop -t 9999999 -f %i)
wmctrl -a $wid
xdotool key $movebind
}
hide()
{
wid=$(slop -t 9999999 -f %i)
wmctrl -i -r $wid -b add,hidden
}
case $1 in
delete)
delete;;
new)
new;;
resize)
resize;;
move)
move;;
hide)
hide;;
esac