Thursday, June 23, 2011

Emulate Middle-Click in Ubuntu

If you don't have a middle-click button at your mouse, or if you are using a laptop touchpad or a trackball, you can emulate the middle-click if needed. One method is to press the left and right buttons simultanously. But at least in the case of a trackball, that doesn't help much.

So, what we are going to do, is just assigning an unused key, for example the <Menu> key, or a key combination to a keyboard shortcut for the command:

xdotool click 2

You need to install the package "xdotool" for that:

sudo apt-get install xdotool

Unfortunately, assigning a modkey + mouse-click combination is a bit tricky and doesn't work reliable, depending on how fast you release the respective modkey, and there is also the potential to screw up the state of those modkey. Also, because of the default modkey + mouse-click combinations, only the right-click comes into question for such a combination. Just in case you want to try that, this is an example for a needed extended command, in this case the modkey is <Control>:

xdotool keyup Control; xdotool click 2

I recommend setting up any of those shortcuts in "CompizConfig Settings Manager > Commands", but you could also set up at least the keyboard shortcut in "Keyboard Shortcuts".

Related Posts:

Launcher , Unity , Usability