Browse Source

Add Pointer Center script

Samuel W. Flint 4 years ago
parent
commit
c2463939e8
1 changed files with 16 additions and 0 deletions
  1. 16 0
      center-pointer

+ 16 - 0
center-pointer

@@ -0,0 +1,16 @@
+#!/bin/sh
+
+HERE=`xdotool getwindowfocus`
+
+ULX=`xwininfo -id $HERE | grep "  Absolute upper-left X:" | awk '{print $4}'`
+ULY=`xwininfo -id $HERE | grep "  Absolute upper-left Y:" | awk '{print $4}'`
+
+# If there is no window, ULX == 1 and ULY == 1.
+if [ $ULX != "-1" -o $ULY != "-1" ]; then
+    eval `xdotool getwindowgeometry --shell $HERE`
+
+    NX=`expr $WIDTH / 2`
+    NY=`expr $HEIGHT / 2`
+
+    xdotool mousemove --window $WINDOW $NX $NY
+fi