How can I configure the mouse thumb button. For example, if I want it to act as a double click.
My mouse is Microsoft Notebook Mouse 5000 Bluetooth (if it matters) and I use Natty.
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It only takes a minute to sign up.Sign up to join this community
By installing a couple packages you can configure this pretty easily without too much trouble at all. No matter what version of Linux I'm using i am always sure to install two specific applications when it comes to mouse and keyboard emulation.
xautomation is a set of command line programs to control X and do "visual scraping" to find things on the screen. There are six different programs to this application but the one we are gonna be concerning ourself with is
xte. This program allows us to send arbitrary mouse and keyboard events to the kernel by utilizing the "XTest" extension.
sudo apt-get install xautomation
xbindkeys is a program that enables us to bind commands to certain keys or key combinations on the keyboard and is window manager independent, so whether you are in Gnome, Unity, KDE, etc... it makes no difference.
sudo apt-get install xbindkeys
****By using these two programs together we can make the keyboard and mouse do just about anything we want them to.***
You say you want to use the thumb button in your case for instance, well first we need to find what "mouse button number"
X Server is recognizing when you click it. We will use a useful tool called
xev to run this program do the following:
1. Open up a terminal window and type the following command at the prompt
It will open an event handler on your screen that looks like the following:
The xev application, showing keycodes
Xev creates a window and then asks the X server to send it events whenever anything happens to the window (such as it being moved, resized, typed in, clicked in, etc.). You can also attach it to an existing window. It is useful for seeing what causes events to occur and to display the information that they contain; it is essentially a debugging and development tool, and should not be needed in normal usage.
Hover your mouse over the event window that opened on your screen and click your thumb button. You will see alot of things happening in your terminal window but the one thing that we are concerned with is the "button number" of the one you just clicked. This can be found at the bottom of your terminal window and should look something similar to the following line:
state 0x10, button 1, same_screen YES
The button part is what were interested in. Being yours is a thumb button its probably gonna say
button 8 or
button 9 but it could be any number. Remember or write down that number for we will use it later. You can now close
xev we no longer need this program.
Now to get things working!!
Assuming you have installed the
xautomation and xbindkeys applications as stated above, we will go ahead and do the following:
2. Open up your favorite text editor and create a new file inside your home directory called
.xbindkeysrc this is the configuration file that
xbindkeys is going to use to make your mouse or keyboard do the special things we'd like it to do.
3. Type the following inside the file:
"xte 'mouseclick 1' 'mouseclick 1'"
b:X + Release
Note: **Be sure to replace
X with whatever number you wrote down for your thumb button from when we ran
Note: **There should also be no spaces between the first line and the second line. If you have a space you will get an error when you run xbindkeys.*
Whats were telling
xbindkeys to do here is to take the action of clicking and releasing your thumb button and make it do the action of double clicking your left mouse button which is represented but
4. Save the file and we should be good to go.
Ok lets test it out!!
5. Open a terminal window and type the following so we can test the functionality:
xbindkeys -n -v
This will run the
xbindkeys program in debug mode so that we can see whats happening when you click on your button. It will tell you that its reading the
.xbindkeysrc file that we created and using it for its configuration. If all goes well then you should end up with a line saying
Now if you click on your thumb button on your mouse then you should see some things happening in your terminal, meaning that it's recognizing the button press. You should now be getting the same functionality as you would by double-clicking with the left button of your mouse.
You should be able to test this out by using the thumb button and clicking on the menu bar of the terminal, which should maximize or minimize it, thus doing the same thing as a double click would do with the left mouse button.
<Ctrl +C> and exit the program.
Note: In order for this all to work all the time, we need to have xbindkeys running in the background at all times. If you just add a new command
xbindkeys without the -n -v in your startup applications then it will start everytime you log in to your window manager.
I've tried to explain in the best detail on how to go about doing this, hopefully you have been able to understand and complete this action with success. :)
The official Ubuntu forums have a page on this - and to configure up to 7 mouse buttons you don't need any extra software.
From that page, use the command:
xinput set-button-map 1 2 3 6 7, replacing those numbers with your required button mapping