Toward a Linux touchpad as smooth as Macbook Pro

Update: After continuing to use my system, I opted for the Synaptics driver instead. Learn why in my follow-up.

As a longtime Macbook Pro user, I’ve grown an insatiable appetite for exceptional hardware+software implementations of laptop functionality like suspend/wake, bluetooth, wifi, and touchpad.  If there’s anything that my past Linux laptops taught me, it’s that these functions are not automatically perfect [insert shock here]. They seem easy & perfect only when they work flawlessly, and they work flawlessly only because Apple employs large teams of experts to test & polish the hardware/software interplay on a Macbook such that it feels perfect.

Since Apple gave me and the rest of the Developer community the heave-ho with its decisions on the latest generation of Macbook Pro [1], it has been a long & harsh journey toward getting a laptop experience that feels as flawless as my Macbook Pro did. But after weeks of experimentation, I wanted to share my current touchpad setup, which feels like it is approaching the buttery smoothness of my past Macbook Pros.

Touchpad options

There are two good articles on setting up a touchpad with Linux (Arch, Antergos, Debian, Ubuntu et al). As these articles explain it, there are three touchpad drivers available on Linux: synaptics (no longer supported), libinput, and mtrack. Preferring to avoid starting with abandonware, I narrowed my search down to libinput and mtrack. The choice between these options was made easier by reading the libinput philosophy not to implement features that aren’t likely to be needed by mainstream users. In their words: “In the old synaptics driver, we added options whenever something new came up and we tried to make those options generic. This was a big mistake… we’re having none of that” Practically speaking, this means that the limit of configurability in libinput is far more limited than the 1,001 settings offered by mtrack.

This isn’t to say that mtrack is a flawless choice. This is not a driver being supported and tested by teams of users & experts. It has no visual settings panel that I’m aware of, all configuration is done via text file. And the correct version to install is initially ambiguous. The officially developed version hasn’t been advanced since 2015, so a popular fork has taken up the torch in recent years. This is why Dayne’s Medium Post recommends installing directly via git. And I recommend the same.

Installing mtrack

Here are the basics to get the latest mtrack installed on your system:

cd /tmp
git clone
cd xf86-input-mtrack
./configure --with-xorg-module-dir=/usr/lib/xorg/modules
sudo make install

At this point you’ll have mtrack’s driver files built/installed, but Xorg still calls the shots in enabling it vs other drivers. By default, mtrack’s xorg configuration file gets placed in /usr/shared/X11/xorg.conf.d/50-mtrack.conf, which in my case meant its precedence was lower than both synaptics (placed in /etc/X11/xorg.conf.d, which takes precedence over the /usr/shared/X11/xorg.conf.d directory) and libinput (which initially had an alphanumerically lower file name (40-libinput.conf) than 50-mtrack.conf. To fix these issues, your best bet is to move your mtrack.conf file to a location/filename with higher precedence:

sudo mv /usr/share/X11/xorg.conf.d/50-mtrack.conf /etc/X11/xorg.conf.d/10-mtrack.conf

Once you’ve done these steps, mtrack should become your default touchpad driver after restarting X server. Of course, this being Linux, there is no single answer as to most easily restart X server. These people think that you can simply run startx, but that didn’t work for me without sudo, and when I ran it with sudo, I ended up setting root permissions on a file (~/.Xauthority) that prevented me from logging in. This well-rated response thinks you can sudo restart lightdm, which did work for me (albeit with different syntax since I’m on arch), but still ended up logging me out, so my official recommendation for re-starting X server is unfortunately to log out then log back in. At that point, if you run cat /var/log/Xorg.0.log | grep mtrack you should see a series of messages that show mtrack being loaded. If you don’t, this was the best thread I found for diagnosing what input driver is actually being used. If you find anything interesting, please do post it to the comments.

Crafting the dream touchpad experience

Once you get mtrack functional, then begins the process of creating a configuration file that best approximates Macbook Pro settings.  Here is my annotated config file:

Section "InputClass"
MatchIsTouchpad "on"
Identifier      "Touchpads"
MatchDevicePath "/dev/input/event*"
Driver          "mtrack"
# Sensitivity controls how fast your cursor will move. 1 is the default
Option          "Sensitivity" "1.1"
Option          "FingerHigh" "5"
Option          "FingerLow" "5"
Option          "IgnoreThumb" "true"
Option          "ThumbRatio" "70"
Option          "ThumbSize" "25"
Option          "IgnorePalm" "true"
# This ignores tap-to-click, which causes more problems than benefit in my experience
Option          "TapButton1" "0"
Option          "TapButton2" "0"
Option          "TapButton3" "0"
# If you want a middle-click, then "ClickFinger2" should be value "2"
Option          "ClickFinger1" "1"
Option          "ClickFinger2" "1"
Option          "ClickFinger3" "3"
Option          "ButtonMoveEmulate" "true"
Option          "ButtonIntegrated" "true"
Option		"ButtonEnable" "true"
# "ButtonZonesEnable" means that your trackpad gets divided into three equal sections, where clicking any third of the touchpad sends the click code in "ClickFingerX". Since I didn't want middle-click, the left two thirds of my touchpad are left click, and the right third is right click:
Option          "ButtonZonesEnable" "true"
Option          "ClickTime" "25"
# Ensures that bottom 5% of touchpad doesn't register taps
Option          "EdgeBottomSize" "5"
Option          "SwipeLeftButton" "8"
Option          "SwipeRightButton" "9"
Option          "SwipeUpButton" "0"
Option          "SwipeDownButton" "0"
Option          "SwipeDistance" "700"
# ScrollCoast makes touchpad feel a bit more Mac-like, although it coasts in chunks and isn't relative to speed at which two finger scroll was happening
Option          "ScrollCoastDuration" "600"
Option          "ScrollCoastEnableSpeed" "0.05"
# This sets up Macbook-like natural scroll. If you want to scroll down by swiping your fingers down, reverse the "5" and the "4" here:
Option          "ScrollUpButton" "5"
Option          "ScrollDownButton" "4"
Option          "ScrollLeftButton" "7"
Option          "ScrollRightButton" "6"
# Without this option set to a high value, there are types of click+hold-and-move functionality (most easily reproed by click and then move up-right) that get ignored
Option          "Hold1Move1StationaryMaxMove" "1000"
# Smaller ScrollDistance translates to faster scrolling. ScrollDistance of 10 scrolls a long page in one swipe.
Option          "ScrollDistance" "22"
Option		"ScrollClickTime" "12"
Option		"ScrollSensitivity" "0"

In a more perfect world, Wordpest wouldn’t have removed the indentation in that block. It is not the world in which we live.

Future improvements

Compared to the miserable touchpad experience I had endured with synaptics and libinput, it has been delightful to get reliable two-finger scrolling that coasts, and to get my two-finger scroll speed comparable to what feels normal from my time in OS X. Still on my list to try to improve the configuration as I move forward:

  • Fix the couple pixels that touchpad tends to stray when I am setting down my thumb in an attempt to click (classic Linux touchpad annoyance)
  • When beginning a new scroll action while coast is active, scroll occurs at 10x normal speed
  • Setup two-finger scrolling to work as smoothly as OS X, rather than scrolling the page in small, discrete increments
  • Determine if it’s somehow possible to restart X server without getting logged out (unlikely, given how much Googling I’ve done on this topic)

[1] While the touch bar is as bad for programming as numerous developers predicted, it was minuscule amount key travel inherent in their butterfly keys that served as my breaking point. Honorable mentions to the laptop hard crashing every few days, and the touchpad that is so impossibly large as to occasionally pick up spurious input (although their software integration makes that problem occur a fraction as often as it would for a comparable Linux laptop)

5 Replies to “Toward a Linux touchpad as smooth as Macbook Pro”

  1. I used the same thing on my linux mint dell laptop, and it’s pretty decent. I am also shifting to linux because of the reasons mentioned above and this is as near to as I have seen. I just need your help with two things, how to get touchpad to cover slightly more distance than it does now in one swipe ?

  2. Hey Aniessh,
    I’m getting an error on ubuntu 18.04 when running make and add dependencies, can you help, please?
    jan@ThinkPad:/tmp/xf86-input-mtrack$ make
    make all-am
    make[1]: Entering directory ‘/tmp/xf86-input-mtrack’
    CC src/capabilities.lo
    In file included from ./include/capabilities.h:25:0,
    from src/capabilities.c:22:
    ./include/common.h:35:10: fatal error: mtdev-mapping.h: No such file or directory
    compilation terminated.
    Makefile:614: recipe for target ‘src/capabilities.lo’ failed
    make[1]: *** [src/capabilities.lo] Error 1
    make[1]: Leaving directory ‘/tmp/xf86-input-mtrack’
    Makefile:419: recipe for target ‘all’ failed
    make: *** [all] Error 2
    jan@ThinkPad:/tmp/xf86-input-mtrack$ sudo apt build-dep xserver-xorg-input-mtrack
    Reading package lists… Done
    E: You must put some ‘source’ URIs in your sources.list

  3. I can’t build it due to a old xorg-server. I get the following error:

    “configure: error: Package requirements (xorg-server >= 1.7 xproto inputproto ) were not met:

    No package ‘xorg-server’ found
    No package ‘xproto’ found
    No package ‘inputproto’ found”

    I’m using the latest elementary OS (0.4.1 LOKI)

    is there any work around?

Leave a Reply

Your email address will not be published. Required fields are marked *