Skip to content

Instantly share code, notes, and snippets.

@swarminglogic
Created July 2, 2013 11:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save swarminglogic/5908530 to your computer and use it in GitHub Desktop.
Save swarminglogic/5908530 to your computer and use it in GitHub Desktop.
Script to move mouse cursor to the specified screen (for separate x screens).
#!/bin/bash
# Script to move mouse cursor to the specified screen (for separate x screens).
# Useful if set up to trigger with a global hotkey.
#
# e.g.: ./focusscreen.sh 0
#
if [ ! `which xdotool` ] ; then echo "You need xdotool!" && exit ; fi
eval $(xdotool getmouselocation --shell 2>/dev/null)
screen=$SCREEN;
if [[ $# -eq 0 ]] ; then exit ; fi
if [[ $1 -eq $screen ]] ; then exit ; fi
xdotool mousemove --screen $1 300 5
# TODO swarminglogic, 2013-07-02: Store screen and mouse position in file when
# switching to a different screen. Check if
# information is available, and if so, move to
# this position if moving to this screen.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment