Light touch regulation#
Wed, 02 Oct 2019 23:34:42 +0000
Or less obliquely, how to configure the Thinkpad X1 Carbon (gen 4, if it matters) touchpad in NixOS to not respond to the lightest brush of a finger as if it were a click. An end to accidentally favouriting random tweets while browsing Twitter on Firefox. Or at least, I hope, the elimination of a significant source of such.
First off, the instructions at
https://people.freedesktop.org/~whot/libinput-rtd/touchpad-pressure.html#touchpad-pressure-hwdb
are very nearly all true, and you should read them because I am not going to recapitulate them. I say "almost" because I found that where it says list-quirks
I
had to say quirks list
instead. Following that process led me to create a file /etc/libinput/local-overrides.quirks
that reads as follows:
[Section touchpad pressure] MatchUdevType=touchpad MatchName=*SynPS/2 Synaptics TouchPad MatchDMIModalias=dmi:*svnLENOVO:*:pvrThinkPadX1Carbon4th* AttrPressureRange=45:42
Second, it's more complicated than that. In NixOS 19.03, the libinput
binary doesn't look at that file, it looks at /nix/store/9lwm03xqd8pkbxc3hgq9iiginddiyha3-libinput-1.12.6/etc/libinput/local-overrides.quirks
, which is owned by the libinput derivation and can't be changed. (This is probably a bug. I will report it in the morning). Because I am trying to stick to channels and not maintain more forks of nixpkgs than I need to, I decided to patch it with an overlay. Therefore
[dan@noetbook:~]$ cat /etc/nixos/overlays/libinput.nix self : super: { libinput = super.libinput.overrideAttrs (o: { mesonFlags = o.mesonFlags ++ [ "--sysconfdir=/etc" ]; }); }
and
[dan@noetbook:~]$ grep -B1 -A9 overlays /etc/nixos/configuration.nix { nixpkgs.overlays = [ (import /etc/nixos/overlays/libinput.nix) ]; environment.etc."libinput/local-overrides.quirks" = { text = '' [Section touchpad pressure] MatchUdevType=touchpad MatchName=*SynPS/2 Synaptics TouchPad MatchDMIModalias=dmi:*svnLENOVO:*:pvrThinkPadX1Carbon4th* AttrPressureRange=45:42 ''; };
and nixos-rebuild switch
, and after some swearing caused mostly by
accidentally forgetting to exit all the nix-shells I had accidentally
got myself into, about 30 minutes rebuilding later, it worked.
Note that adding overlays in configuration.nix does not make them
available to nix-env
or nix run
, so you probably also want to add
libinput to environment.systemPackages
if you want to test your
quirks are getting picked up. Then you can do this:
[dan@noetbook:~]$ strace -e openat libinput quirks list /dev/input/event7 2>&1 |grep etc openat(AT_FDCWD, "/etc/libinput/local-overrides.quirks", O_RDONLY) = 3[dan@noetbook:~]$ libinput quirks list /dev/input/event7 ModelSynapticsSerialTouchpad=1 AttrPressureRange=45:42 AttrThumbPressureThreshold=100
A great improvement / A+++ would recommend. Wish I'd done it three years ago.