Using Percentages in the 'windowmove' Command

198 views
Skip to first unread message

Bastien Dejean

unread,
Nov 14, 2011, 8:42:28 AM11/14/11
to xdotoo...@googlegroups.com
Hi,

I was wondering if any patch had been written to add support for
percentages in the 'windowmove' command?

Greetings,
--
Bastien

Icaria

unread,
Nov 17, 2011, 12:33:14 AM11/17/11
to xdotool-users
You can do this with a bit of scripting. A sample of my scripts.

Move window on the X axis (absolute positioning):

================

#!/bin/bash

#scr=`cat ~/.scrres | sed -e 's/\([0-9]*\)x\([0-9]*\)/\1/'`
scr=1920
panels=40
dectop=19
decbottom=2
decleft=2
decright=2
#let scr=$scr-$panels
let fract=$scr/$1*$2

actwin=`xdotool getactivewindow`

#x=`xwininfo -id $actwin -stats | head -n 4 | tail -n 1 | sed -e 's/
*Absolute upper-left X: *\([0-9]*\)/\1/'`
x=$fract

y=`xwininfo -id $actwin -stats | head -n 5 | tail -n 1 | sed -e 's/
*Absolute upper-left Y: *\([0-9]*\)/\1/'`

#let netx=$x-$decleft

#let x=$x-$decleft
let y=$y-$dectop

#let x=$x+$fract

#let mod=$netx%$fract

#let x=$x-$mod

xdotool windowmove $actwin $x $y --sync
sleep 0.05
xdotool windowfocus $actwin

===================

Move window on the Y axis (cumulative ie. groks current window
position and adds/subtracts from it):

===================

#!/bin/bash

#scr=`cat ~/.scrres | sed -e 's/\([0-9]*\)x\([0-9]*\)/\2/'`
scr=1080
panels=40
dectop=19
decbottom=2
decleft=2
decright=2
let scr=$scr-$panels
let fract=$scr/$1*$2

actwin=`xdotool getactivewindow`

x=`xwininfo -id $actwin -stats | head -n 4 | tail -n 1 | sed -e 's/
*Absolute upper-left X: *\([0-9]*\)/\1/'`

y=`xwininfo -id $actwin -stats | head -n 5 | tail -n 1 | sed -e 's/
*Absolute upper-left Y: *\([0-9]*\)/\1/'`

let nety=$y-$panels

let x=$x-$decleft
let y=$y-$dectop

let y=$y+$fract

let mod=$nety%$fract

let y=$y-$mod

xdotool windowmove $actwin $x $y --sync
sleep 0.05
xdotool windowfocus $actwin

================

The arguments for the scripts are one integer for the screen divisor
and another integer for the multiplier ie. 'wm_y_cu.sh 10 -1' divides
the vertical screen resolution in to 10 rows and moves the window back
one row. 'wm_x.sh 20 5' divides the horizontal resolution in to 20
columns and moves the window to the 5th column.

Hope that helps.

Anthony Thyssen

unread,
Nov 17, 2011, 2:11:35 AM11/17/11
to xdotoo...@googlegroups.com

You can get the window position using xdotool itself using

xdotool getactivewindow getwindowgeometry -shell

I wrote a script that will 'bounce' 'shake' etc a given window
to get the users attention.

The script uses xdotool to do the job.
http://www.ict.griffith.edu.au/anthony/software/jiggle_window.xdotool.sh

One problem I have however is that the xdotool seems to have trouble
reporting window positions correctly when "openbox" window manage frame
extents are present.


Now the xdotool position, I try and move the current window 1 pixel
upward.

eval $(xdotool getactivewindow getwindowgeometry -shell)
xdotool windowmove -sync $WINDOW $X $((Y-1))

On my screen my window jumps down and right about twice the
amount the window manager added as extra framing around the window.

Basically the xdotool returned position info is just not correct.

What is actually happening is that xdotool returns a position that
is "xwininfo"s Absolute coordinate + Relative Coordinate!


This is the fix (which is in the above script) that I have found to work,
at least until xdotool position info is fixed. I basically need to subtract
the windows framing extents twice.

eval $(xdotool getactivewindow getwindowgeometry -shell)

set -$- $( xprop -id $WINDOW _NET_FRAME_EXTENTS | tr -cs '0-9' ' ' )
X=$(( $X - 2 * ${1:-0} )) # Window manager correction
Y=$(( $Y - 2 * ${3:-0} ))

xdotool windowmove -sync $WINDOW $X $((Y-1))

Now the window moves correctly 1 pixel upward!


I hope this is of help.


(my xdotool version is currently 2.20110628.1)

Anthony Thyssen ( System Programmer ) <A.Th...@griffith.edu.au>
--------------------------------------------------------------------------
There are bugs and there are bugs. And then there are bugs.
--------------------------------------------------------------------------
Anthony's Castle http://www.ict.griffith.edu.au/anthony/

Reply all
Reply to author
Forward
0 new messages