dotfiles/.local/bin/i3cmds/hover
2020-07-04 14:23:27 +02:00

23 lines
1.1 KiB
Bash
Executable File

#!/bin/sh
[ -z "$1" ] && exit # If $1 is left, hovers in the bottom left, if right, the bottom right
current=$(xdotool getwindowfocus)
newwidth=$(($(xdotool getdisplaygeometry | awk '{print $2}') / 3))
newheight=$(($(xdotool getdisplaygeometry | awk '{print $1}') / 3))
centerwidth=$(( $(xdotool getdisplaygeometry | awk '{print $1}') / 2))
newsize=$(xdotool getwindowgeometry "$current" | grep Geometry | sed -e 's/x/ /g' | awk '{print $3}')
newwidth=$(xdotool getwindowgeometry "$current" | grep Geometry | grep -o " [0-9]*")
baroffset=47
case "$1" in
left) horizontal=0; vertical=$(($(xdotool getdisplaygeometry | awk '{print $2}') - newsize)) ;;
right) horizontal=$(($(xdotool getdisplaygeometry | awk '{print $1}') - newwidth)) ; vertical=$(($(xdotool getdisplaygeometry | awk '{print $2}') - newsize)) ;;
center) echo "$centerwidth"
horizontal=$(( ( $(xdotool getdisplaygeometry | awk '{print $1}') - centerwidth ) / 2 ));
vertical=$baroffset
newheight=$(( $(xdotool getdisplaygeometry | awk '{print $2}' ) - baroffset -5))
newwidth=$centerwidth;;
esac
xdotool windowsize "$current" $newwidth $newheight
xdotool windowmove "$current" $horizontal $vertical