winm

A simple script for window mgmt on xfce4
Log | Files | Refs | README

commit f23861318cc963e3483edf82c7eaa78ef4884497
parent 5ffa9e41697f3e60e7d2248d5333e377496d31ac
Author: Naveen Narayanan <zerous@nocebo.space>
Date:   Sun,  7 Jul 2024 04:24:25 +0200

Use an offset to get exact position

xwininfo reports the absolute x and y positions with an offset.
Account for it whilst calculating new positions. Implement
moveup and movedown.

Diffstat:
Mxfce4wm | 42++++++++++++++++++++++++++++++++++++++----
1 file changed, 38 insertions(+), 4 deletions(-)

diff --git a/xfce4wm b/xfce4wm @@ -5,7 +5,7 @@ # determine what windows are maximized and re-max after the "window select" function # determine what windows are non-resizable by the user so that the script doesn't resize them # cascade also shaded windows - +set -x # which workspace we're on function get_workspace { if [[ "$DTOP" == "" ]] ; then @@ -226,7 +226,9 @@ function win_moveright { -e "s/^ \+Width: \+\([0-9]\+\).*/w=\1/p" \ -e "s/^ \+Height: \+\([0-9]\+\).*/h=\1/p" ) #echo -n "$x $y $w $h" - xdotool getactivewindow windowmove --sync $((x+25)) 0 + k=$((x-1)) + z=$((y-22)) + xdotool getactivewindow windowmove --sync $((k+25)) $z } function win_moveleft { @@ -235,8 +237,34 @@ function win_moveleft { -e "s/^ \+Absolute upper-left Y: \+\([0-9]\+\).*/y=\1/p" \ -e "s/^ \+Width: \+\([0-9]\+\).*/w=\1/p" \ -e "s/^ \+Height: \+\([0-9]\+\).*/h=\1/p" ) - #echo -n "$x $y $w $h" - xdotool getactivewindow windowmove --sync $((x-25)) 0 + echo -n "$x $y $w $h" + k=$((x-1)) + z=$((y-22)) + xdotool getactivewindow windowmove --sync $((k-25)) $z +} + +function win_moveup { + eval $(xwininfo -id $(xdotool getactivewindow) | + sed -n -e "s/^ \+Absolute upper-left X: \+\([0-9]\+\).*/x=\1/p" \ + -e "s/^ \+Absolute upper-left Y: \+\([0-9]\+\).*/y=\1/p" \ + -e "s/^ \+Width: \+\([0-9]\+\).*/w=\1/p" \ + -e "s/^ \+Height: \+\([0-9]\+\).*/h=\1/p" ) + echo -n "$x $y $w $h" + k=$((x-1)) + z=$((y-22)) + xdotool getactivewindow windowmove --sync $k $((z-25)) +} + +function win_movedown { + eval $(xwininfo -id $(xdotool getactivewindow) | + sed -n -e "s/^ \+Absolute upper-left X: \+\([0-9]\+\).*/x=\1/p" \ + -e "s/^ \+Absolute upper-left Y: \+\([0-9]\+\).*/y=\1/p" \ + -e "s/^ \+Width: \+\([0-9]\+\).*/w=\1/p" \ + -e "s/^ \+Height: \+\([0-9]\+\).*/h=\1/p" ) + echo -n "$x $y $w $h" + k=$((x-1)) + z=$((y-22)) + xdotool getactivewindow windowmove --sync $k $((z+25)) } for command in ${@} ; do @@ -270,6 +298,12 @@ for command in ${@} ; do elif [[ "$command" == 'moveleft' ]] then win_moveleft + elif [[ "$command" == 'moveup' ]] + then + win_moveup + elif [[ "$command" == 'movedown' ]] + then + win_movedown elif [[ "$command" == 'shrinkvertical' ]] then win_shrinkvert