Thursday, June 21, 2007

Right-Clicking With a One-Button Mouse (Ubuntu)

I recently encountered some one who was running Ubuntu on a non-mac system, yet was stuck with only a one-button mouse. The problem is the issue of right-clicking.

I found a nifty little program called mouseemu which allows you make a key press act as a mouse click. To get it working, simly do the following.

First, you need to install the mouseemu package. You can do this through synaptic or apt-get as follows:

sudo apt-get install mouseemu


Once it is installed you'll want to modify /etc/defaults/mouseemu because unless it detects a PowerPC system it won't set up any keys by default.

Inside /etc/defaults/mouseemu you will find options to set the various clicks. These are exactly as described by the man page and are simply passed as arguments to the daemon when it starts up. You can find a full list of the scan codes in /usr/include/linux/input.h. You want the decimal number after the #define KEY_ entry.

For example the following give the codes for the keys F8 through F12.

#define KEY_F8 66
#define KEY_F9 67
#define KEY_F10 68
#define KEY_F11 87
#define KEY_F12 88


These are scancodes and if you want to use a modify you need to find the scan code for that one too.

Once you have those two numbers you simply uncomment the line for the desired action and insert the right scan codes. For example, to make F12 with no modifiers do a right-click I would have the following line:


RIGHT_CLICK="-right 0 88"


Note that you can only have one key per button, so you can't make multiple buttons map to the same mouse click. The last one in the file is the one that gets used.

After you have set up your /etc/defaults/mouseemu, restart the daemon and things should work without too much trouble. To restart the daemon run the following from the command line.

sudo /etc/init.d/mouseemu restart


And you should have a right-click whenever you hit the F12 button.

No comments: