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

  1. ivan@orion:~$ apt-cache search input move

gave me this:

  1. 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:

  1. ivan@orion:~$ xdotool --help
  2. Available commands:
  3. getactivewindow
  4. getwindowfocus
  5. getwindowpid
  6. search
  7. help
  8. version
  9. click
  10. getmouselocation
  11. key
  12. keydown
  13. keyup
  14. mousedown
  15. mousemove
  16. mousemove_relative
  17. mouseup
  18. type
  19. windowactivate
  20. windowfocus
  21. windowmap
  22. windowmove
  23. windowraise
  24. windowsize
  25. windowunmap
  26. set_window
  27. set_num_desktops
  28. get_num_desktops
  29. set_desktop
  30. get_desktop
  31. set_desktop_for_window
  32. get_desktop_for_window
  33. ivan@orion:~$ xdotool getmouselocation
  34. x:379 y:361 screen:0
  35. 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:

Compiz Commands
Compiz Commands

Compiz Command Key
Compiz Command Key