1 { config, lib, options, pkgs, ... }:
5 let cfg = config.services.xserver.synaptics;
6 opt = options.services.xserver.synaptics;
7 tapConfig = if cfg.tapButtons then enabledTapConfig else disabledTapConfig;
9 Option "MaxTapTime" "180"
10 Option "MaxTapMove" "220"
11 Option "TapButton1" "${builtins.elemAt cfg.fingersMap 0}"
12 Option "TapButton2" "${builtins.elemAt cfg.fingersMap 1}"
13 Option "TapButton3" "${builtins.elemAt cfg.fingersMap 2}"
15 disabledTapConfig = ''
16 Option "MaxTapTime" "0"
17 Option "MaxTapMove" "0"
18 Option "TapButton1" "0"
19 Option "TapButton2" "0"
20 Option "TapButton3" "0"
22 pkg = pkgs.xorg.xf86inputsynaptics;
23 etcFile = "X11/xorg.conf.d/70-synaptics.conf";
28 services.xserver.synaptics = {
33 description = "Whether to enable touchpad support. Deprecated: Consider services.libinput.enable.";
37 type = types.nullOr types.str;
39 example = "/dev/input/event0";
41 Path for touchpad device. Set to null to apply to any
42 auto-detected touchpad.
46 accelFactor = mkOption {
47 type = types.nullOr types.str;
49 description = "Cursor acceleration (how fast speed increases from minSpeed to maxSpeed).";
53 type = types.nullOr types.str;
55 description = "Cursor speed factor for precision finger motion.";
59 type = types.nullOr types.str;
61 description = "Cursor speed factor for highest-speed finger motion.";
64 scrollDelta = mkOption {
65 type = types.nullOr types.int;
68 description = "Move distance of the finger for a scroll event.";
71 twoFingerScroll = mkOption {
74 description = "Whether to enable two-finger drag-scrolling. Overridden by horizTwoFingerScroll and vertTwoFingerScroll.";
77 horizTwoFingerScroll = mkOption {
79 default = cfg.twoFingerScroll;
80 defaultText = literalExpression "config.${opt.twoFingerScroll}";
81 description = "Whether to enable horizontal two-finger drag-scrolling.";
84 vertTwoFingerScroll = mkOption {
86 default = cfg.twoFingerScroll;
87 defaultText = literalExpression "config.${opt.twoFingerScroll}";
88 description = "Whether to enable vertical two-finger drag-scrolling.";
91 horizEdgeScroll = mkOption {
93 default = ! cfg.horizTwoFingerScroll;
94 defaultText = literalExpression "! config.${opt.horizTwoFingerScroll}";
95 description = "Whether to enable horizontal edge drag-scrolling.";
98 vertEdgeScroll = mkOption {
100 default = ! cfg.vertTwoFingerScroll;
101 defaultText = literalExpression "! config.${opt.vertTwoFingerScroll}";
102 description = "Whether to enable vertical edge drag-scrolling.";
105 tapButtons = mkOption {
108 description = "Whether to enable tap buttons.";
111 buttonsMap = mkOption {
112 type = types.listOf types.int;
115 description = "Remap touchpad buttons.";
116 apply = map toString;
119 fingersMap = mkOption {
120 type = types.listOf types.int;
123 description = "Remap several-fingers taps.";
124 apply = map toString;
127 palmDetect = mkOption {
130 description = "Whether to enable palm detection (hardware support required)";
133 palmMinWidth = mkOption {
134 type = types.nullOr types.int;
137 description = "Minimum finger width at which touch is considered a palm";
140 palmMinZ = mkOption {
141 type = types.nullOr types.int;
144 description = "Minimum finger pressure at which touch is considered a palm";
147 horizontalScroll = mkOption {
150 description = "Whether to enable horizontal scrolling (on touchpad)";
153 additionalOptions = mkOption {
157 Option "RTCornerButton" "2"
158 Option "RBCornerButton" "3"
161 Additional options for synaptics touchpad driver.
170 config = mkIf cfg.enable {
172 services.xserver.modules = [ pkg.out ];
174 environment.etc.${etcFile}.source =
175 "${pkg.out}/share/X11/xorg.conf.d/70-synaptics.conf";
177 environment.systemPackages = [ pkg ];
179 services.xserver.config =
181 # Automatically enable the synaptics driver for all touchpads.
183 Identifier "synaptics touchpad catchall"
185 ${optionalString (cfg.dev != null) ''MatchDevicePath "${cfg.dev}"''}
187 ${optionalString (cfg.minSpeed != null) ''Option "MinSpeed" "${cfg.minSpeed}"''}
188 ${optionalString (cfg.maxSpeed != null) ''Option "MaxSpeed" "${cfg.maxSpeed}"''}
189 ${optionalString (cfg.accelFactor != null) ''Option "AccelFactor" "${cfg.accelFactor}"''}
190 ${optionalString cfg.tapButtons tapConfig}
191 Option "ClickFinger1" "${builtins.elemAt cfg.buttonsMap 0}"
192 Option "ClickFinger2" "${builtins.elemAt cfg.buttonsMap 1}"
193 Option "ClickFinger3" "${builtins.elemAt cfg.buttonsMap 2}"
194 Option "VertTwoFingerScroll" "${if cfg.vertTwoFingerScroll then "1" else "0"}"
195 Option "HorizTwoFingerScroll" "${if cfg.horizTwoFingerScroll then "1" else "0"}"
196 Option "VertEdgeScroll" "${if cfg.vertEdgeScroll then "1" else "0"}"
197 Option "HorizEdgeScroll" "${if cfg.horizEdgeScroll then "1" else "0"}"
198 ${optionalString cfg.palmDetect ''Option "PalmDetect" "1"''}
199 ${optionalString (cfg.palmMinWidth != null) ''Option "PalmMinWidth" "${toString cfg.palmMinWidth}"''}
200 ${optionalString (cfg.palmMinZ != null) ''Option "PalmMinZ" "${toString cfg.palmMinZ}"''}
201 ${optionalString (cfg.scrollDelta != null) ''Option "VertScrollDelta" "${toString cfg.scrollDelta}"''}
202 ${if !cfg.horizontalScroll then ''Option "HorizScrollDelta" "0"''
203 else (optionalString (cfg.scrollDelta != null) ''Option "HorizScrollDelta" "${toString cfg.scrollDelta}"'')}
204 ${cfg.additionalOptions}
210 assertion = !config.services.libinput.enable;
211 message = "Synaptics and libinput are incompatible, you cannot enable both.";