Created
January 6, 2012 18:08
-
-
Save tremby/1571701 to your computer and use it in GitHub Desktop.
topleft -- move mouse pointer to top left of current screen
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# check for binaries | |
type -P xmousepos &>/dev/null || { | |
echo "can't find xmousepos -- install xautomation" >&2 | |
exit 1 | |
} | |
type -P xte &>/dev/null || { | |
echo "can't find xte -- install xautomation" >&2 | |
exit 1 | |
} | |
# get current horizontal mouse position | |
mousex=$(xmousepos | awk '{print $1}') | |
# walk through widths of screens (assuming they're in order left to right) until | |
# the mouse is on the current screen, building offset from left | |
offset=0 | |
for width in $(xrandr | grep '*' | awk '{print $1}' | sed -r 's/x.*//'); do | |
[ $mousex -lt $(expr $offset + $width) ] && break | |
offset=$(expr $offset + $width) | |
done | |
# move the pointer to the top left of the screen | |
xte "mousemove $offset 0" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment