I just got 2 Asus ML228 wide-screen monitors, this is a big update from my previous monitors resolution that were 1280x760, and they were not wide-screen, so it took me a while to get used to these wide screen displays, I have them in Full HD via DVI to HDMI connector, and i’m using nVidia twinview instead of Xinerama because I can use compiz with twiview and not with Xinerama, the total display I get from both monitors is 3840x1080 pixels (966x272 millimeters), so I have to move my hand a lot to switch between one monitor and the other with the mouse, I also have my laptop on the left because that is were i have my chat and email apps, so to get there from the right screen I have to move even more my hand until I get to the end of the mousepad.
A friend of mine recommend to use a program to switch between my two monitors with a hotkey, he told me the program he used for windows, I look for it, and I didnt found anything that could work in linux, because I was to busy I left that, until this past week where I just got tired to move from one window to another to check my tests, so I checked again what were my options, and again didnt found nothing that was simple to run.
I knew that I could leverage the commands plugin from compiz to grab the hotkeys, I just needed a way to move the cursor, so I did a quick search in the aptitude repository
ivan@orion:~$ apt-cache search input move
gave me this:
xdotool - simulate X11 keyboard/mouse input
That looked like the thing i was looking for, so i’ve installed
xdotool and started playing with it, i quickly found that this little tool has a lot of choices that can be used for many, many things, so what I did to achieve my goal was the following:
ivan@orion:~$ xdotool --help Available commands: getactivewindow getwindowfocus getwindowpid search help version click getmouselocation key keydown keyup mousedown mousemove mousemove_relative mouseup type windowactivate windowfocus windowmap windowmove windowraise windowsize windowunmap set_window set_num_desktops get_num_desktops set_desktop get_desktop set_desktop_for_window get_desktop_for_window ivan@orion:~$ xdotool getmouselocation x:379 y:361 screen:0 ivan@orion:~$ xdotool mousemove 800 200
and with that my pointer moved to a random position 🙂 (800x200) I moved the mouse to the center of left screen and used
getmouselocation to get the screen coordinates, I did the same for right screen and with this parameters i’ve opened my compiz configuration and created the following 2 hotkeys: