zenUtils/rio.sh

72 lines
1.1 KiB
Bash
Raw Permalink Normal View History

2021-11-28 03:50:19 +00:00
#!/bin/sh
termprog="st"
2021-11-28 03:50:19 +00:00
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}')
wmctrl -l > ~/.wl
2021-11-28 03:50:19 +00:00
$termprog -g 80x24+${x}+${y}&
2021-11-28 03:50:19 +00:00
while true; do
lastCreatedID=$(wmctrl -l | tail -n 1 | awk '{print $1}')
if [ "$lastCreatedID" != "$(tail -n 1 ~/.wl | awk '{print $1}')" ]; then
2021-11-28 03:50:19 +00:00
break
fi
done
wmctrl -i -r $lastCreatedID -e 0,$geom
rm ~/.wl
2021-11-28 03:50:19 +00:00
}
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
}
# swap mouse buttons so we can use right button like in rio
xmodmap -e 'pointer = 3 2 1'
2021-11-28 03:50:19 +00:00
case $1 in
delete)
delete;;
new)
new;;
resize)
resize;;
move)
move;;
hide)
hide;;
esac
# restore original mouse config
xmodmap -e 'pointer = 1 2 3'