Fixing natural scrolling in Ubuntu 12.04Posted: May 27, 2012
I recently “upgraded” my HP laptop from Fedora 16 to Ubuntu 12.04 and, as I always do, tried to set up natural scrolling on it. Obviously, I had to run into a problem – in this case, the new “smooth scrolling” implementation Ubuntu uses.
Smooth scrolling was introduced in GTK 3.4, which a few things (like the file manager) use now. However, it doesn’t rely on the standard “button”-based scrolling standard (you roll the scroll wheel a bit, the mouse sends it as a button press), but on a more precise reporting of scroll distance that some touchpads provide. Only Synaptics touchpads are supported for now, I think.
Anyway, my previous natural scrolling method hacks into the “normal” scrolling method, and not the one used by GTK 3.4, so a new approach is needed. Enter xinput.
$ xinput list
⎡ Virtual core pointer id=2 [master pointer (3)]
⎜ ↳ Virtual core XTEST pointer id=4 [slave pointer (2)]
⎜ ↳ SynPS/2 Synaptics TouchPad id=11 [slave pointer (2)]
⎣ Virtual core keyboard id=3 [master keyboard (2)]
$ xinput list-props 11 | grep "Scrolling Distance"
Synaptics Scrolling Distance (288): 106, 106
Synaptics Circular Scrolling Distance (301): 0.100000
So, what did I do there? The first step is, obviously, to open a terminal window so you can copy-paste those things. With Unity, just hit the Super/Windows key, type “terminal” and hit Enter.
Then you’ll have to copy-paste the first command,
xinput list, and hit Enter. Two notes I want to make here, for terminal newbies: firstly, don’t copy the
$ – that represents the prompt you should already have on your screen. Secondly, paste using the right click menu in a terminal, not Ctrl-V.
Look around the listing for your Synaptics touchpad – I’ve put mine in italics. If you don’t find one, smooth scrolling should be off, and you should be able to use these instructions to set natural scrolling up. If you do find one, make a note of its ID (in my case, it was 11).
Next, you’ll have to run the second command,
xinput list-props 11 | grep "Scrolling Distance", replacing the 11 in italics with the ID you found in the previous step. Another note for terminal newbies: use the arrow keys to move through the pasted command. You should get one or two lines as a reply – make a note of the number in parentheses next to “Synaptics Scrolling Distance” – mine was 288 – and the previous values – mine were both 106.
Next up, open the file manager and create a new empty file somewhere (I have it in my ~/Scripts directory). Call it, say,
NaturalScrolling.sh. Open it up in gedit and copy-paste this in it, replacing the italicized properties with the numbers you found in the previous steps:
xinput set-prop 11 288 -106 -106
nautilus -n &
(The last two lines quit the file manager, and then restart it in desktop-only mode, which should work around all possible related bugs.)
Save it, right click it in the file manager, go to the Permissions tab and check “Allow this file to be executed” (or something along those lines – I’m not on my Ubuntu machine). This script will set the new scrolling distance properties (which are basically the negatives of the previous ones) and restart the file manager.
Now, we need to set this to run on boot. Thankfully, Ubuntu makes that easy – just go to the system menu in the top right corner, click “Startup Applications”, click the “Add” button, give the entry a name (say, “Natural Scrolling”) and browse to wherever you saved the script.
Next, reboot and enjoy – it’ll hopefully work now. You could do worse than leave a comment if I helped. Note that this could also work on Fedora 17 and other distros implementing GTK 3.4′s smooth scrolling – no guarantees though, and you’ll have to tweak at least the “run on boot” part of the instructions.
If you run into any problems, first make sure you have no .Xmodmap file in your home folder (you could have one if, say, you followed my other natural scrolling setup guide), that your system is up to date (this fix only works with new versions of the Synaptics driver), and reboot again for good measure. If it doesn’t work after that, leave a comment and I’ll try to help you.
The obligatory hat tip goes to “RAOF” from the Ars Technica forums, who seems to be the first to have come up with this fix.