I would like to be able to move the mouse pointer in a perfectly straight line. I am looking for a way to use two modifier key combinations, one of them making the mouse pointer move only horizontally, while moving vertically in just the normal way. It would be like I move the mouse itself only along a vertical ruler, with the mouse oriented perfectly parallel to the ruler. And the same feature for horizontal movement only, using different modifier keys, or key sequences.
I am interested in partial solutions for this too, like a command line program to limit the movement, or a different way to change the movement mode with the keyboard. Or even some kind of local "configuration hack".
A god example for the use of this feature is to allow to use the thumbnail bar in a YouTube video without the need to keep the mouse inside the horizontal range manually.
11 Answer
Workaround:
get your screen resolution first and change the values in the script.
Sample Content for Vertical Movement, Change the value 768 with your screen vertical resolution.
borderxl=$XPOS
borderyu=0
borderxr=$XPOS
borderyd=768Sample Content for Horizontal Movement, Change the value 1366 with your screen Horizontal resolution.
borderxl=0
borderyu=$YPOS
borderxr=1366
borderyd=$YPOSOriginal Script is from this Post & the Credit also goes to this Post Keep Mouse Within Circle
Modified Script:
#!/bin/bash
POS=$(xdotool getmouselocation | sed 's/:/ /g')
XPOS=$(echo $POS | cut -d' ' -f2)
YPOS=$(echo $POS | cut -d' ' -f4)
borderxl=0
borderyu=$YPOS
borderxr=1366
borderyd=$YPOS
check=0
if [ $borderxl -gt $borderxr ]
then check=1
fi
if [ $borderyu -gt $borderyd ]
then check=1
fi
if [ $check -ge "1" ]
then echo "Make sure the first coordinate pair refers to the upper left corner" echo "and the second pair refers to the lower right one."
fi
if [ $check -lt "1" ]
then while [ true ] do check=0 xpos=`xdotool getmouselocation | awk '{ print $1}'` xpos=${xpos:2} #xpos=`getcurpos | awk '{ print $1}'` ypos=`xdotool getmouselocation | awk '{ print $2}'` ypos=${ypos:2} #ypos=`getcurpos | awk '{ print $2}'` if [ $xpos -gt $borderxr ] then check=1 xpos=$borderxr fi if [ $ypos -gt $borderyd ] then check=1 ypos=$borderyd fi if [ $xpos -lt $borderxl ] then check=1 xpos=$borderxl fi if [ $ypos -lt $borderyu ] then check=1 ypos=$borderyu fi if [ $check -ge "1" ] then xdotool mousemove $xpos $ypos fi done
fiProblemes with the script.
Creating shortcut keys for these two scripts, I could not find a way to kill the process, force logging out is the only way. Initially I have created shortcut keys Alt+x and Alt+y both works perfectly.. but killing the process, I could not achieve.