Simulating Two-Finger Scrolling in Linux

posted in: Linux | 3

Finger hovering over laptop touchpad

Ubuntu (and possibly your Linux distribution) comes with support for notebook/netbook touchpads. If you are a laptop person, you probably have a love/hate relationship with your touchpad or trackpad. You might love finger-tapping to simulate your button-pressing, or you might hate it. Similarly, two-finger scrolling is something I have come to love, but others out there might despise it. It depends on your preferences (and possibly the width of your finger – more on that later).

If you do like two-finger scrolling, you were probably disappointed when you discovered your fresh new Linux laptop did not have it enabled. You can scroll with one finger on the right edge of the touchpad, but that is just not the same.

To enable two-finger scrolling and other multitouch features (not to be confused with multipass features) is actually quite easy with the “xinput” command. Before you get to enabling multitouch, you might want to try out a few things. Open a terminal and type the following:

xinput list

 

This will give you a list of input devices, one of which will hopefully be your Synaptics touchpad. It should be listed under “Virtual core point” as something like “SynPS/2 Synaptics TouchPad”. After you know the name, you can find out its current settings with:

xinput list-props “SynPS/2 Synaptics TouchPad”

It will print out a bunch of information, and you should see Two-finger scrolling on the list, but it will probably have a 0, 0 indicating it is disabled. To enable two-finger scrolling, paste each of these lines in succession, pressing enter after each one:

xinput --set-prop --type=int --format=32 "SynPS/2 Synaptics TouchPad" "Synaptics Two-Finger Pressure" 4
xinput --set-prop --type=int --format=32 "SynPS/2 Synaptics TouchPad" "Synaptics Two-Finger Width" 8
xinput --set-prop --type=int --format=8  "SynPS/2 Synaptics TouchPad" "Synaptics Two-Finger Scrolling" 1 0

Two-finger scrolling should now work, but the problem is, once you restart your computer or even log out of your desktop, you will be right back where you started. The solution is to make a startup script.

1. First create a plain text file called touchpad.sh. I like to keep it in /home/username/bin, but you can put it where you are sure you will not accidentally delete it.

2. Edit the file (with gedit in Gnome or kate in KDE)

3. Add the above-mentioned lines. You might also want to turn off edge scrolling, and if you are like me, you will disable tapping too. Another extra line will make two-finger scrolling smoother.

#!/bin/sh

xinput --set-prop --type=int --format=32 "SynPS/2 Synaptics TouchPad" "Synaptics Two-Finger Pressure" 4

xinput --set-prop --type=int --format=32 "SynPS/2 Synaptics TouchPad" "Synaptics Two-Finger Width" 8         # Below width 1 finger touch, above width simulate 2 finger touch. - value=pad-pixels

xinput --set-prop --type=int --format=8  "SynPS/2 Synaptics TouchPad" "Synaptics Two-Finger Scrolling" 1 0   # vertical scrolling, horizontal scrolling - values: 0=disable 1=enable

xinput --set-prop --type=int --format=8  "SynPS/2 Synaptics TouchPad" "Synaptics Edge Scrolling" 0 0 0       # vertical, horizontal, corner - values: 0=disable  1=enable

xinput --set-prop --type=int --format=32 "SynPS/2 Synaptics TouchPad" "Synaptics Jumpy Cursor Threshold" 250 # stabilize 2 finger actions - value=pad-pixels

xinput --set-prop --type=int --format=8  "SynPS/2 Synaptics TouchPad" "Synaptics Tap Action" 0 0 0 0 0 0 0   # pad corners rt rb lt lb tap fingers 1 2 3 (can't simulate more then 2 tap fingers AFAIK) - values: 0=disable 1=left 2=middle 3=right etc. (in FF 8=back 9=forward)

exit

NOTE: If you find yourself accidentally scrolling with your single large finger, you can increase the “Two Finger Width” setting to compensate.

4. Once you have all of the lines entered, save the file.

5. Before the file will work like a program, you need to make it executable. In most file managers, you can right click, click properties, and find an “executable” check box. From a terminal, you can just enter: [code=”bash””””””]chmod a+x touchpad.sh[/code]

6. Click on your script or run it from the terminal to test it:

./touchpad.sh

 

7. Finally, make your script launch at startup.

In KDE, go to System Settings -> Startup and Shutdown -> Autostart -> Add Script.

In Gnome, go to System -> Preferences -> Startup Applications -> Add.

You can alternatively drop the script into /home/username/.config/autostart and/or /home/username/.kde/share/autostart.

From now on you will have two-finger scrolling bliss and never have to worry about it again.

3 Responses

  1. Tiberius Nougat

    Thank you so much for posting this! I managed to get this type of gesturing to work on my other laptop, but I do not at all recall how; I think I copied someone else’s script which performs the same configurations as your helpful howto here, just less transparently. You’ve helped me actually understand how to actually make this work, as opposed to relying on someone else.

    Minor quibble: I had to change all your double quotes to single quotes for my shell to accept the quoted contents and actually pass them to the command in question, then all worked fine. Also I just edited the script with vi, but to each his own.

Write a comment