Ubuntu 8.10 Intrepid Ibex – mouse configuration

I always seem to have hassles with my mouse setup in Ubuntu.

I have an old Microsoft Comfort Optical 3000 Mouse which I’ve been using for years. It’s a fine mouse, apart from the middle-click button. I use middle-click a lot when I’m surfing to open and close tabs. I don’t like the middle button on my mouse because you have to push it really, really hard. However, there is a little thumb button which is a perfect replacement. So I have always changed the mouse mappings and swapped the middle click functions onto the thumb button. This is remarkably easy to do in Windows – probably because I’m using a Microsoft mouse. I simply opened the Mouse options in Control Panel and a little picture of the mouse would be displayed showing all the buttons and I changed whatever options I wanted in the menus. Unfortunately, it’s not quite so simple in Ubuntu.

When I first installed Ubuntu (and really had no idea what I was doing), I found it quite difficult to change the button mappings over. Sure there was a lot of documentation, but most of it was over my head. I did figure it out eventually – mostly because I am a stubborn bitch and will not allow a computer to beat me – and, like anything, once you know how, it’s pretty easy.

I decided to upgrade from Hardy Heron to Intrepid Ibex, which – so far – seems to have gone well. However my thumb button wasn’t working as it should. No problem, I thought, the xorg.conf has probably been reset to a default file. I just need to edit it and change my settings. Of course nothing is ever that simple. When I opened my xorg.conf file, a line had been inserted reading # commented out by update-manager, HAL is now used. I had no idea what HAL was (though I kept thinking of the computer in 2001: A Space Odyssey!). But I digress. HAL apparently stands for hardware abstraction layer if you’re interested (more info here). This is all well and good, but how the hell do I fix my mouse buttons?

After some Googling and trawling of the Ubuntu forums, I am writing below what worked for me. (This is as much a reference for myself, for when I next break my system and can’t remember what I did).

Firstly, you have to know which mouse button corresponds to which mapping number. This is pretty easy. Open a terminal and type xev and press enter. This will open the event viewer. This will give you a little white square which you can click on and a whole load of text will appear in the terminal. Try clicking once with the left mouse button and you should get something like this:

ConfigureNotify event, serial 34, synthetic YES, window 0×3a00001,
event 0×3a00001, window 0×3a00001, (669,49), width 178, height 178,
border_width 2, above 0×120b42b, override NO

ButtonRelease event, serial 34, synthetic NO, window 0×3a00001,
root 0×1a6, subw 0×3a00002, time 9122614, (28,35), root: (699,86),
state 0×110,button 1, same_screen YES

The only part that matters is the button number, which I have highlighted above. Try clicking again with the right mouse button, and you will probably get Button 3 for that. This lets you know which button is which. In my particular setup the middle click button is Button 2 and the thumb button is Button 9, so bascially I want to swap these two over.

Next, you have to create a policy file for your mouse. I copied some text I found for a Logitech mouse and tweaked it to suit. I opened Gedit and inserted the following text:

<?xml version=”1.0″ encoding=”ISO-8859-1″?>
<deviceinfo version=”0.2″>
<device>
<match key=”info.capabilities” contains=”input.mouse”>
<merge key=”input.x11_driver” type=”string”>mouse</merge>
<!– mouse tweaks –>
<match key=”info.product” string=”Microsoft Comfort Optical Mouse 3000″>
<merge key=”input.x11_options.ButtonMapping” type=”string”>1 9 3 8 2</merge>
<merge key=”input.x11_options.EmulateWheel” type=”string”>true</merge>
<merge key=”input.x11_options.EmulateWheelButton” type=”string”>8</merge>
<merge key=”input.x11_options.ZAxisMapping” type=”string”>4 5</merge>
<merge key=”input.x11_options.Emulate3Buttons” type=”string”>true</merge>
</match>
</match>
</match>
</match>
</match>
</device>
</deviceinfo>

I changed the mouse name and button mappings to suit my particular mouse, though it advised me in the original article that button mappings were being ignored, but I’ll get to that in a minute.

I saved this file into my Documents directory first, just so that I have a copy for when I break my system again! I called my file mouse.fdi (you can call it whatever name you want but you need the .fdi extension). Next, I opened the terminal and copied this file to the correct Ubuntu directory. If the file is in the Documents folder in your Home directory, use the following command:

sudo cp Documents/mouse.fdi /etc/hal/fdi/policy/

Stage 1 complete, however all the documentation I found told me I’d have to edit xmodmap to tweak the button mappings. I searched for the file and tried to open it with Gedit, but Ubuntu wouldn’t let me. I had no idea how to edit this file and most web sites just said ‘add this text to your xmodmap‘. Yes, but HOW??

Open Gedit and insert the following text:

pointer = 1 9 3 4 5 6 7 8 2

I have swapped buttons 9 and 2 over to suit my particular set up, however these can be changed to whatever you need. Now save this file and call it .xmodmap (you need the dot at the start of the name). Save this file into your username folder (i.e. /home/YourUserName) and that should be it. You need to log out, then log back in again. The first time I did this, a little box popped up asking if I wanted to load the second xmodmap file. I clicked on both the system version and my version to load them both up and hallelujah my mouse is working!

I really like Ubuntu and still haven’t booted into Windows after my last disaster, but this is a helluva hassle for people who aren’t that familiar with computers. I enjoy tinkering and learning something new, but it shouldn’t be this hard to swap a couple of mouse buttons over. Linux for human beings isn’t quite there yet.

10 Comments

  1. Burkay Genc
    Posted 9 November, 2008 at 12:04 pm | Permalink

    You don’t really need to do the first .fdi part. All you want is to map the buttons, which is done by xmodmap. So all you have to do is to create the .xmodmap file in your home directory and that fixes the button mappings. At least, that is what worked for my Microsoft Intellimouse Explorer 2.0 under intrepid. Thanks for the detailed explanations.

  2. mesanna
    Posted 11 November, 2008 at 8:49 pm | Permalink

    Thank you Burkay Genc!! I didn’t know you could do that.

    I deleted my .fdi file and it worked just fine. Just for fun, I also tried creating an .xmodmap file on another PC that I have running Linux Mint (which is based on Ubuntu Hardy) and it tweaked my mouse buttons exactly the way I wanted. I didn’t need to mess about with the xorg.conf file at all. Why isn’t this modification more widely publicized for us noobs? Everything I found on the web either indicated that you had to edit the xorg.conf file (in Hardy) or follow the steps above (in Intrepid). Thank you taking the time to let me know about this, it’s sooo much easier :)

  3. olivierlemaire
    Posted 11 December, 2008 at 10:52 am | Permalink

    Hi,
    so, this is the new way to configure our devices. I wanna do the same for a “MX Revolution” logitech. Where did you fond the information to create your own fdi file ?? I mean, for example, where does the button mapping is coming from…
    thank you for your help.

  4. mesanna
    Posted 16 December, 2008 at 10:47 pm | Permalink

    Hi olivierlemaire, Sorry for not responding sooner, blame the Christmas rush! I’m not personally familiar with your Logitech mnouse, but I would think the procedure would be much the same as in the article.

    To figure out the mapping number for each mouse button, open xev (I’ve given the details in the article above). You just click in the little white square and the text that appears in the terminal includes the button number. Click each mouse button one at a time and note the number. Also scroll up and scroll down with the wheel, as these will have a button mapping number too.

    Once you know the numbers for each button, try just creating an xmodmap file first and see if that works (it’s a lot simpler than creating an fdi file). I thought you HAD to create an fdi file until another poster pointed out that you don’t. So just try creating the xmodmap file, then log out/log in again and see if this works.

    I can’t remember now where I found the fdi file text. It might have been here:

    https://wiki.ubuntu.com/X/Config/Input

    There’s some info on Logitech mice on that page, plus a couple of links that may be helpful.

    Hope this info is useful, let me know if you need any more help.
    :)

  5. Frisco Rose
    Posted 12 January, 2009 at 4:34 pm | Permalink

    WRT the difficulty of pushing the middle button, try pulling the button toward you. I think they engineered the mouse to have middle click be a different direction than right/left tilt in order to avoid middle-click/side-scroll event conflation.

  6. Cruncher
    Posted 24 February, 2009 at 6:19 am | Permalink

    Firstly, Linux is case sensitive, and according to /etc/X11/Xsession.d/80ubuntu-xmodmap the filename needs to be .Xmodmap (capital X). Consequently, .xmodmap did not work for me.
    Secondly, suppose you want to keep the original mapping of your button #2, how can you do that? Using “pointer = 1 2 3 4 5 6 7 8 2″ does not work, xmodmap will return an error if a button is listed *twice* – apparently you can only *exchange* button mappings with that. What is the solution for that?
    Thanks

  7. Posted 24 February, 2009 at 11:09 am | Permalink

    “the filename needs to be .Xmodmap (capital X)”
    Hmmm, I do realise that Linux is case-sensitive, however .xmodmap worked fine for me and was picked up right away when I logged out and back in again.

    “Secondly, suppose you want to keep the original mapping of your button #2, how can you do that?”
    I’m not sure I understand what you’re asking. If you want Button 2 to remain as Button 2, then just leave it as it is! The whole point of the article was that I wanted to swap the functionaility of buttons 2 and 9 (the middle click and thumb buttons on my system).

    Thanks for your comment.

  8. Cruncher
    Posted 24 February, 2009 at 3:58 pm | Permalink

    Hm, interesting that .xmodmap worked for you (and others?).
    What I meant in the second part is, I want to have the functionality of mouse button 2 when I press either button 2, 6 or 10 (in my case). But that might not be possible with the normal mapping functions.

  9. cid
    Posted 2 April, 2009 at 9:43 am | Permalink

    I have an A4Tech Optical Mouse WOP-35 and installed Ubuntu 8.10.
    My default xorg.cong fine didn’t include any InputDevice section nor did it say that HAL is now used.

    I did this and it worked:

    1. type
    sudo gedit /etc/X11/xorg.conf

    2. insert

    Section “InputDevice”
    Identifier “Configured Mouse”
    Driver “mouse”
    Option “CorePointer”
    Option “Device” “/dev/input/mice”
    Option “Protocol” “ExplorerPS/2″
    Option “ZAxisMapping” “6 7 4 5″
    Option “Buttons” “9″
    EndSection

    Save file

    3. type
    sudo gedit .xmodmap

    4.insert

    pointer = 1 2 3 4 5 8 9 6 7

    Resart X by pressing Ctrl+Alt+Backspace

    That’s it

  10. cid
    Posted 2 April, 2009 at 9:45 am | Permalink

    I mean my default xorg.conf file.
    Although .cong would be more Ubuntu-like. :)

Post a Comment

Your email is never shared. Required fields are marked *

*
*