Move pointer to middle of screen, multi-head.

Short script (in python) to shift mouse pointer to middle of screen, useful to save time on low acceleration pointing devices. Works for multi-head setups.

#!/usr/bin/env python
# Small script to jump pointer to middle of given screen number
# Run with [scriptname] [screen number]
import os, sys

modelines = os.popen("xrandr | grep -v ^[A-Z] | grep + | sed s/^'   '//g")


for i,line in enumerate(modelines.readlines()):
    mode = line.split(' ')[0]

    if (str(i) == sys.argv[1]):
        y = int(mode.split('x')[1])/2
    x = int(mode.split('x')[0])/2
    totalx += x
    os.system('xdotool mousemove ' + str(totalx) + ' ' + str(y))

    x = int(mode.split('x')[0])
    totalx += x