Lion like scrolling on Ubuntu – Inverse scrolling on Linux

Mac OSX Lion Logo

Lion, the latest operating sytem for mac from Apple.

Any one who has upgraded to Mac OS 10.7 Lion will will have had the new inverted scrolling (natural, as Apple call it) which I described in my last post.

However, while many may have found it irritating at first but chose to power through and get used to it, have got too used to it.  Now, other computers seem just wrong.

I hate it when it turns out Apple were right but it would seem that moving the page up and down rather than the scroll bar really is just, natural.

So here’s how you Linux folk can get Lion like scrolling working on your computer.  I’ve been using Ubuntu but I’m sure we’ll see it working on other distributions.

Right then, open up your terminal, let’s get going. You can click on any of these screen shots to see larger versions.

Your first command is:

xinput list

This will show you a list of devices, work out which one is your trackpad or mouse. From my screenshot, you can see that my Trackpad’s ID is 13.

Now that you know this, it’s time for your second command, incorporating the ID you have found out.

xinput test 13

Replace the 13 with whatever your device ID was.

Now scroll up a little and then scroll down a little, finally press Ctrl+C to end the test. From this you can see the mapping of your scroll function. In my screen shot you can see that my scrolling up as button 4 and scrolling down as button 5, obviously they’re not really buttons but you’re not supposed to think of that ;]

Work out what your scroll button numbers are, you’re going to need them.

Now for the actual change, the button mapping of your device will be set up as something like 1 2 3 4 5. In my case; 1, 2 and 3 are likely left, right and middle button; 4 and 5 we know for my case are the scroll, obviously they may be different for you, take note of these along with the device number you already know.

So of course all we’re needing to do is swap these round, here we go:

xinput set-button-map 13 1 2 3 5 4

Now pay attention to how that’s made up; we’ve got your device number in there (I’m 13 remember) and we’ve flipped round the numbers that we know are mapped to our scrolling, (5 and 4)… also, while I’m patronising you like this, don’t forget those spaces. Now go try it out, look, it’s working! Aren’t you clever.

You’re not done yet!

All you’ve done is make it work for now, the moment you restart your computer, it’s going to go away so let’s just make this thing permanent shall we?

Now you can set up an xorg option (Option zAxisMapping “5 4″) but I’m still in my patronising mood and thinking I should just give you the easy option so all we’re going to do is take that last command we typed in (xinput set-button-map 13 1 2 3 5 4) and make it run on startup.

So open up your System Settings and choose Startup Applications.

Now just click Add and type in the command along with a Name and description. You’re all done, you’re natural Lion like scrolling is all done. Congratulations, you may roar, raaaaaaaaaaaaaa.

A link to this post

  • http://james-bennet.com James Bennet
    • http://www.andybarratt.co.uk Andy Barratt

      It’s nice but I very much like to avoid solutions that involve installing third party software.

  • eMBee

    very nice indeed, just shows how powerful the X Window system is!

    i usually turn off trackpad scrolling altogether because i really hate how it gets in my way if i accidently touch the edge when mousing around. but maybe with natural scrolling it will be less irritating, so i have to give that a try.

    greetings, eMBee.

    • http://www.andybarratt.co.uk Andy Barratt

      I never used scrolling with trackpad until I had my first apple computer, an iBook G3. Apple had implemented two finger scrolling, something that would be difficult to activate by accident compared to the scrolling with the side of the trackpad which had always made me want to snap my own fingers off. I now see that most computers are being bought with two finger scrolling built into the software. In fact, I bought an Asus machine just two days ago running Windows 7 with this turned on by default. On Ubuntu, you can turn two finger scrolling on in the system settings, I highly recomend giving it a go if accidental scrolling has been a problem in the past :)

  • http://twitter.com/teenix Steven ⚡

    “other computers [scrolling] seem just wrong”.. exactly so. #lion Also I swapped 6 and 7 to get horizontal scrolling, this using a mighty mouse. `xinput set-button-map 17 1 2 3 5 4 7 6 8 9 10 11 12` .. thanks!!

  • Craig Weber

    Thank you, kind Sir. I also figured out that I *can* change two-finger tap to right-click, unlike virtually every Internet resource I looked at previously. So thank you sooooo much for both of these things.

  • http://twitter.com/probals Probal Shome

    Worked like a charm on Mint Linux 12. The same concept can be used to invert the horizontal scrolling too, but I hardly ever use it.

    Thanks again.

    P

  • Alexandre Strube

    You forgot the side scroll too. Would be something like
    xinput set-button-map 13 1 2 3 5 4 7 6

  • Pingback: Инвертированный скролл в Линуксе | DS

  • Micke Karlsson

    To view your current “button-map”, run:
    xinput get-button-map [id]
    where [id] is the device id of your trackpad.

  • oschrock

    Awesome! Thanks!

  • Christoph Ruepprich

    Sweet! Now my Acer One with Linux Mint is good enough so that I don’t have to buy a MacBook Air! Thanks.
    BTW: In Linux mint the startup applications are under Preferences.

  • WhatTheTech

    This is fantastic. Just downloaded Chrubuntu on my Samsung Chromebook and this worked on both the trackpad and an external mouse. Many thanks for a great tutorial!

  • Soroosh

    You are awsome, this is fantastic! also the xorg option is fairly easy since at least mine had the Option zAxisMapping “4 5″ and I simply swaped them.

  • Vishal

    Awesome article man! I was searching for something just like this! Thanks a lot :]

  • guest_diego

    not working on linux mint 14 cinnamon

  • Fred

    you’ve forgot the hypens. It’s xinput set-button-map, but xinput –set-button-map

  • RoKaï

    just awesome!! works perfect on synaptic touchpad with ubuntu. So smart and easy.. thanks!!

  • Mr. Guest

    That was perfect, thank you!!!