I have a mouse with lots of buttons, but it's not a mainstream make like Logitech. For Windows, I have a driver that lets me assign actions like close-window (Ctrl+W) or next-tab (Ctrl+Tab), but I don't have a Linux driver. Since Linux is so flexible, I thought perhaps there is a general way to do this, regardless of brand?

Update: Based on input from Cyrex, I installed and ran sudo apt-get install btnx which found several but not all mouse buttons.
Found: left, right, wheel, wheelclick, thumb fwd, thumb back.
Not found: wheel left, wheel right, thumb middle button.
Vendor ID is 0x04d9, Model ID is 0xa015.

Update 2: In System>Prefs>Mouse there's a lightbulb icon for testing double-click speed. Every working button can turn the bulb on&off, but the missing buttons can't. It would seem that Ubuntu isn't aware of these buttons and thus doesn't register their clicks. I guess I need to hunt for a driver, though a mainstream mouse is probably the easier way.

  • Please explain what mouse button 9 is.
    – user92200
    Oct 1, 2012 at 19:13
  • @mateo_salta Got that in seconds before me.
    – user92200
    Oct 1, 2012 at 19:14
  • Do you use Unity?
    – int_ua
    Oct 1, 2012 at 19:15
  • What make and model is it?
    – user92200
    Oct 1, 2012 at 19:19
  • @int_ua Yes, I strive use a system configuration as close to the default as I can tolerate.
    – ændrük
    Oct 1, 2012 at 19:23

11 Answers 11


I have a MX Anywhere "M-R0001"

I use my forward and Back buttons as Copy and Paste.

1) All buttons are detected with last kernel... at least with

uname -a

3.8.0-25-generic #37-Ubuntu SMP Thu Jun 6 20:47:07 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux

2) So, basically, you only need to map those buttons with desired actions. How to know with button is pressed and the correspondent numeric code? Well, you can use the 'xev' program:


This program is a key and mouse events sniffer. When it's running, you can see a window in which you can press mouse buttons and see if they are detected. For example, with the zoom button of the Performance MX you will see something like that:

ButtonPress event, serial 35, synthetic NO, window 0x5800001,
    root 0x15a, subw 0x0, time 64521438, (84,117), root88,144),
    state 0x10, button 13, same_screen YES

that means that 13 is the code for that mouse button. You can try every mouse buttons on your hand ... for easy access, here is the map for Performance MX:

  • Back button: 8
  • Forward button: 9
  • Zoom button: 13
  • Show windows button: 10

the other buttons are well recognized and you don't need to map to actions.

3) Now, you need to install a little program to re-map mouse and keyboard inputs. The magician is 'xbindkeys' ... the easy installation is using:

sudo apt-get install xbindkeys

4) Once installed, you can do the magic. The idea is configure the mouse buttons to send key combinations to activate other desktop functionalities (as the matter of fact, xbindkeys can be used for execute any other program when you press a mouse button). In KDE you can do that with Ctrl+F10 keys combination. The point is create a xbindkeys' configuration file to do the job.

5) To create the configuration file, just run the following command:

xbindkeys --defaults > $HOME/.xbindkeysrc

6) And we need to edit the file to specify your button's mapping:

gedit $HOME/.xbindkeysrc

7) We need to add our button-to-key configurations. For example, I have the following:

# Back changed to Copy
"xte 'keydown Control_L' 'key C' 'keyup Control_L'"

# Forward
"xte 'keydown Alt_L' 'key Right' 'keyup Alt_L'"

# Present desktops
"xte 'keydown Control_L' 'key F8' 'keyup Control_L'"

# Present windows
"xte 'keydown Control_L' 'key F10' 'keyup Control_L'"

8) There was a new requirement. the 'xte' program, which basically simulates user key press combinations. Install it using:

sudo apt-get install xautomation

Now, if you run on a terminal something like:

xte 'keydown Control_L' 'key F10' 'keyup Control_L'

that means simulate a Ctrl+F10 keypress. The idea is using xbindkeys to say: "when I press 13th mouse button, send a Ctrl+F10 keyboard press using xte program to generate that"

9) And finally, you need to configure 'xbindkeys' to run automatically on system startup. Startup Applications / Add program button and type '/usr/bin/xbindkeys' on the dialog.


  • 12
    Also, as a note, it's usually easier to grep xev with xev | grep button for mouse buttons..
    – Seth
    Jun 16, 2013 at 19:54
  • 1
    Works great for me, except I didn't have to write a script to make it start with my computer for some reason. Thanks! Oct 7, 2017 at 12:43
  • 1
    How would I go about making a mouse button so it acts like a different mouse button? This seems to be for keys in particular. For instance, I want button 8 to act like pressing the mousewheel button. Is that possible with xte? Oct 7, 2017 at 12:54
  • @Brōtsyorfuzthrāx I believe you can. If you take a look at man xte you can see that there's a mouseclick action available. You can use it in the configuration file the same way you use keydown or keyup. Just give it the desired mouse button number.
    – itachi
    Apr 29, 2022 at 8:34

enter image description here

Easystroke is a Mouse gesture-recognition application and mouse gesture manager for Ubuntu and Other Linux distribution. it allows user to control ubuntu application with hand drawn mouse gestures or Draw on the Screen. Easystroke work on Tablet PCs, it can be used equally well with a mouse, pen, or even your fingers if you have a touch-sensitive screen.

Install Easystroke in Ubuntu

sudo apt-get install easystroke

If you want installing easystroke via PPA, you can adding a PPA repository, type this command:

sudo add-apt-repository ppa:easystroke/ppa
sudo apt-get update
sudo apt-get install easystroke

For Unity Users : EasyStroke have not used indicator applet yet, so when you run it from menu, you have nothing on Indicator Applet. To solve this problem, simply run these command in terminal:

easystroke -g

It will run EasyStroke and open configuration windows automatically.


  • Didn't recognize the extra buttons on the Logitech G700s. Mar 23, 2017 at 2:42

If all buttons are detected correctly then you can install btnx:

sudo apt-get install btnx OR sudo aptitude install btnx

Then go to: Applications -> System Tools -> Btnx

It has support for many types of mice

  • I tested my mouse with btnx but it didn't recognize all my buttons. Does this indicate a problem with my mouse (driver?) or with btnx (unlikely I guess)? Jan 4, 2011 at 20:57
  • Am guessing between. Maybe the mouse module is not detecting the mouse correctly so btnx does not either. Can you actually click all the buttons and see if a programa recognizes them, like the click test in the mouse settings. Jan 4, 2011 at 21:43
  • 1
    I'm selecting this as the correct answer because btnx allows me to instantly test each mouse button - this proved that Ubuntu simply isn't aware of the extra buttons. I need to get a linux-friendly mouse. Feb 9, 2011 at 7:34
  • 21
    btnx can not be found - has the package changed name?
    – northben
    Sep 10, 2013 at 21:31
  • 2

Easystroke Gesture Recognition is designed primarily for creating custom pointing device gestures, but it can also be used to assign actions to simple button presses.

To use it in this manner,

  1. Open the configuration window.
  2. In Preferences ▸ Behavior ▸ Additional Buttons ▸ Add, select Instant Gestures and then press the desired mouse button in the gray box.

    Easystroke Gesture Recognition - Select a Mouse or Pen Button

  3. In Actions, click Add Action.

  4. Double-click in the Stoke column and then press the desired mouse button again.

  5. Click in the Name, Type and Details columns to set up an action.

    Easystroke Gesture Recognition - Actions

  • The button registers in step 2, but nothing happens in step 4 when pressing it again.
    – Andreas
    Nov 1, 2020 at 14:47
  • "NOTE: As for now, easystroke is in an unmaintained state."
    – Rob Kam
    Jul 14, 2021 at 14:47

If you install the CompizConfig Settings Manager Install CompizConfig Settings Manager then you will be able to set a lot of window management mouse button shortcuts.

It may take some effort working out which button is which.

In the screenshot I am assigning opening the Super+Tab switcher to a left-click of my scroll wheel.



Olli Salonen has his own ppa which needs to be added to your list if you want to install via apt. Here is the info about adding ppa.


Also, this link might help with installing on newer version of Ubuntu since I see Olli isn't active for quite a while now.


Source is here: http://github.com/cdobrich/btnx.git It built and ran on my Linux Mint 13 without problems. Caveat: btnx-config needs to be run with root perms.

  • I tried this and thought it didn't work.. My caveat was that I didn't know that btnx-config is a dependency from a different repository which also needs to be installed. So also this: github.com/cdobrich/btnx-config Aug 29, 2022 at 12:50
  • However, the program is useless to me, I just wanted to be able to create a simlink or choose with a menu what to do after dragging a file/folder Aug 29, 2022 at 13:29

Btnx is available for download from here.


In mid-2017, there doesn't seem to be any updated btnx package for Ubuntu 16.04 LTS, and easystroke also doesn't seem to be maintained any longer.

I wanted to assign copy / paste to the two additional buttons of my (decades-old, but battle-tested) Microsoft IntelliMouse, and finally settled on imwheel, which is described in this page in the Ubuntu Wiki.

For reference, here's my ~/.imwheelrc:

# https://help.ubuntu.com/community/ManyButtonsMouseHowto

None, Thumb1, Shift_L|Control_L|C
None, Thumb2, Shift_L|Control_L|Insert

None, Thumb1, Control_L|C
None, Thumb2, Control_L|V

# vim:ts=4:shiftwidth=4:syntax=sh

To start the tool together with the X server, set IMWHEEL_START=1 in /etc/X11/imwheel/startup.conf.


Accepted answer is outdated, here is the updated version.

You should already have these as they should come with Ubuntu, but run this just in case.

sudo apt-get install libdaemon-dev libglade2-dev libgtk2.0-dev 

Now, download & install

1) btnx-config 2) btnx In this order.

To install:

Unzip, and cd into each of these folders.

In each of them run:

./configure make
sudo make
sudo make install

Once both of them are installed, run

sudo btnx-config

In Configurations tab, click Detect Mouse & Buttons

enter image description here

In Buttons tab, assign your mouse button a key or functionality. Make sure you ☑ check mark enabled.

enter image description here

Lastly, in Configurations tab, click on Restart btx button so your changes take effect.

enter image description here

  • first i downloaded btnx-config and unzipped it. Then ./configure make i get this as last configure: error: /bin/bash config/config.sub make failed and then when i try sudo make it says make: *** No targets specified and no makefile found. Stop.
    – Larry
    Dec 21, 2019 at 20:21
  • Compiling doesn't work on Ubuntu 19.10. I got the same error. I had to compile it on Ubuntu 18.04 and then install it on 19.10.
    – Jerguš
    Jan 21, 2020 at 20:16
  • On Devuan ASCii I have the same error as @Larry. Any solution? Is there a btnx-PPA that works with Devuan ASCii or Lubuntu-QT 20.04?
    – vasilis74
    Aug 23, 2021 at 16:36
  • @No Sssweat @Larry The command ./configure make is wrong. README says ./configure make sudo make install (and sudo make uninstall for uninstalling).
    – vasilis74
    Aug 23, 2021 at 22:35

On modern Ubuntu releases, input-remapper provides a GUI and I think would suit this goal. See How to access extra mouse buttons on Wayland?

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .