at 23.11-pre 3.1 kB view raw
1{ config, lib, ... }: 2 3with lib; 4 5{ 6 ###### interface 7 8 options = { 9 10 hardware.trackpoint = { 11 12 enable = mkOption { 13 default = false; 14 type = types.bool; 15 description = lib.mdDoc '' 16 Enable sensitivity and speed configuration for trackpoints. 17 ''; 18 }; 19 20 sensitivity = mkOption { 21 default = 128; 22 example = 255; 23 type = types.int; 24 description = lib.mdDoc '' 25 Configure the trackpoint sensitivity. By default, the kernel 26 configures 128. 27 ''; 28 }; 29 30 speed = mkOption { 31 default = 97; 32 example = 255; 33 type = types.int; 34 description = lib.mdDoc '' 35 Configure the trackpoint speed. By default, the kernel 36 configures 97. 37 ''; 38 }; 39 40 emulateWheel = mkOption { 41 default = false; 42 type = types.bool; 43 description = lib.mdDoc '' 44 Enable scrolling while holding the middle mouse button. 45 ''; 46 }; 47 48 fakeButtons = mkOption { 49 default = false; 50 type = types.bool; 51 description = lib.mdDoc '' 52 Switch to "bare" PS/2 mouse support in case Trackpoint buttons are not recognized 53 properly. This can happen for example on models like the L430, T450, T450s, on 54 which the Trackpoint buttons are actually a part of the Synaptics touchpad. 55 ''; 56 }; 57 58 device = mkOption { 59 default = "TPPS/2 IBM TrackPoint"; 60 type = types.str; 61 description = lib.mdDoc '' 62 The device name of the trackpoint. You can check with xinput. 63 Some newer devices (example x1c6) use "TPPS/2 Elan TrackPoint". 64 ''; 65 }; 66 67 }; 68 69 }; 70 71 72 ###### implementation 73 74 config = 75 let cfg = config.hardware.trackpoint; in 76 mkMerge [ 77 (mkIf cfg.enable { 78 services.udev.extraRules = 79 '' 80 ACTION=="add|change", SUBSYSTEM=="input", ATTR{name}=="${cfg.device}", ATTR{device/speed}="${toString cfg.speed}", ATTR{device/sensitivity}="${toString cfg.sensitivity}" 81 ''; 82 83 system.activationScripts.trackpoint = 84 '' 85 ${config.systemd.package}/bin/udevadm trigger --attr-match=name="${cfg.device}" 86 ''; 87 }) 88 89 (mkIf (cfg.emulateWheel) { 90 services.xserver.inputClassSections = [ 91 '' 92 Identifier "Trackpoint Wheel Emulation" 93 MatchProduct "${if cfg.fakeButtons then "PS/2 Generic Mouse" else "ETPS/2 Elantech TrackPoint|Elantech PS/2 TrackPoint|TPPS/2 IBM TrackPoint|DualPoint Stick|Synaptics Inc. Composite TouchPad / TrackPoint|ThinkPad USB Keyboard with TrackPoint|USB Trackpoint pointing device|Composite TouchPad / TrackPoint|${cfg.device}"}" 94 MatchDevicePath "/dev/input/event*" 95 Option "EmulateWheel" "true" 96 Option "EmulateWheelButton" "2" 97 Option "Emulate3Buttons" "false" 98 Option "XAxisMapping" "6 7" 99 Option "YAxisMapping" "4 5" 100 '' 101 ]; 102 }) 103 104 (mkIf cfg.fakeButtons { 105 boot.extraModprobeConfig = "options psmouse proto=bare"; 106 }) 107 ]; 108}