IMWheel (5 button mouse within Nautilus) : Ubuntu (6.10)

By | 2006/12/02

Yesterday I promised I would also include instructions on how to setup IMWheel for support for 5 button mouse within Nautilus file manager. These instructions are a little more detailed and require a touch of customization. In my mind, if you’re brave enough to use an abomination mouse you can easily be brave enough to set this up. It shouldn’t take more than 5 minutes and when you’re done you’ll have all the comforts of your 5 button mouse with GNOME and Nautilus. Let’s get started!

  1. sudo aptitude install imwheel
  2. sudo gedit /etc/X11/imwheel/imwheelrc
  3. Add the following to the bottom of the existing file:
  4. ".*"
    None, Up, Alt_L|Left
    None, Down, Alt_L|Right
    None, Up, Alt_L|Left
    None, Down, Alt_L|Right

  5. Create an IMWheel startup script: sudo gedit /usr/bin/mouse
  6. #!/bin/sh
    exec xmodmap -e "pointer = 1 2 3 6 7 4 5" &
    exec imwheel -k -b "67" &

  7. Set this script as executable: sudo chmod +x /usr/bin/mouse

You can optionally set this script up to auto-start at login by adding it to “System > Prefences > Sessions > Startup Programs”. Click “Add” and enter /usr/bin/mouse. Select “OK”.

At this point test IMWheel by restarting GNOME (ctrl-alt-backspace) or restarting the computer. I would love to hear how this works for people as I don’t personally have a 5 button mouse to test this on. If I’ve missed anything please let me know.

12 thoughts on “IMWheel (5 button mouse within Nautilus) : Ubuntu (6.10)

  1. Piet

    Much thanks for this little guide! I’m very new to ubuntu, so I had no idea how to get those buttons working.
    Works excellent, I can now also use my extra mouse buttons in ET again. Yay!

  2. Ubuntu Tutorials

    I’m glad to hear it worked simply for you. That’s what we’re here for.. to save the world, one computer at a time.

  3. Jeroen

    Worked like a charm, but it resulted in having my thumb buttons switched with my scroll-wheel action.

    So I changed my Xorg.conf (changed Option “ZAxisMapping” “4 5” to Option “ZAxisMapping” “6 7”) and added Option “ButtonMapping” “1 2 3 4 5”

    This seemed to fix it…

  4. Specto

    Any chance for a 4 button mouse guide (like Logitech dualoptic)?

  5. Sotec

    Didn’t work at all for me, but it didn’t crash X, so I guess not all bad. I would really love to get my scroll toggles to work in ET. I’m currently using:

    Ubuntu Feisty Fawn (official)
    Logitech G5 Gaming Laser mouse (wired)

    I should clarify that nothing happened when I restarted X. Nothing good, or bad. No change. Any help would be fantastic. My email is:

    [email protected]
    (copy/paste it if you have to, hehe)

    Thanks in advance!

  6. Nick

    Didn’t really work for me. I made the script alright, but it basically gave me this retarded mouse configuration where my mousewheel was my forward and back browsing buttons. =(

  7. Chris

    Upgraded to 8.04 Hardy Heron (with Firefox 3B).
    Broke my back & forward buttons.
    Had to switch buttonmapping from “1 2 3 6 7 8 9” to “1 2 3 8 9 6 7”.
    Wish I knew what it all meant!

  8. franky

    i’ve installed ubuntu 8.04 few days ago .im very new to linux. i did all the steps above and now scrolling is not working anymore(nautilus and firefox). and all other buttons did not work either (back and forward still working with firefox). i have a Logitech MX Laser Mouse. i would really appreciate it, if somebody could help me to get my mouse work. thanks a lot

  9. Danny

    I followed this tutorial, but when I went to test it, scrolling was not working. So I commented the /usr/bin/mouse commands in the file and the wheel now works again.

    Anyone know a simple way to get Nautilus (File Browser) to work with buttons 6 and 7 as a back and forward though the folders? (like in Firefox)


  10. Richard Kimber

    What do the various fields in imwheelrc actually represent?

    And how do you represent more complicated actions than Alt_L? For example pasting from the clipboard.

  11. Seth

    That should answer your first question Richard, and the second one would be:

    Control_L|P #Pasting from the clipboard with ^p

    the names of all the buttons you can put in the first and third fields are anything in your:


    with the leading XK_ omitted.

    To do combinations like a paste, you pipe together the different keysyms you found from that file above, like I did in the example, but it can be more then two, like Ctrl+Alt+Del is


    So the fields in the imwheelrc file are sections each starting with “regular-expression” where the regular-expression is a regex statement that will allow imwheel to figure out what window or windows you mean based on the window’s identifier, the next lines after that are your definitions for what you want the buttons to do, these can be:

    where up and down are the regular scroll wheel up/down left and right apply if you have 4-axises for scrolling, and thumb1 is the left extra button on 4-button mice, and
    thumb2 is the right.

    Rather then mess with all the remapping that most people do, I found that if you can just run “imwheel -k” without errors, it’s much less hassle to just quickly figure out what buttons are actually represented by the names you use in the configuration file and then just change the configuration file so that it works, I was getting all kinds of problems out of nowhere from invoking the -b argument, so for instance on my kensington mouse with 2 axis scroll wheel and 2 thumb buttons, imwheel is thinking that my up is left and my down is right, so this was what I wrote:

    None, Left, Page_Up
    None, Right, Page_Down
    None, Thumb1, Control_L|Left
    None, Thumb2, Control_L|Right

    None, Left, Page_Up
    None, Right, Page_Down
    None, Thumb1, Control_L|Left
    None, Thumb2, Control_L|Right

    “.*” will make the following lines applicable to all windows
    “(null)” will make the following lines applicable to windows that have no identifier
    “\(root\)” will make the following lines applicable in the root window (your desktop or whatever the “main” window is depending on how you are running X)

    The only issue I’m currently having with it is that the focus isn’t working quite right for me, and the extra options in the man page to deal with focus issues aren’t helping, before I started using imwheel, my wheel would focus on hover instead of window selection, but nop the selected window recieves the action from imwheel (like windows, ugh) I havn’t checked back through my gnome-settings to see if they somehow got messed up, but at least I can switch my workspaces with the extra buttons that weren’t doing anything before.

  12. pippo

    it works with our M860 mouse (4 button + scroll)


Comments are closed.