2014-04-14 15:26:48 +01:00
|
|
|
{ config, lib, pkgs, ... }:
|
2009-09-10 13:37:33 +01:00
|
|
|
|
2014-04-14 15:26:48 +01:00
|
|
|
with lib;
|
2009-09-10 13:37:33 +01:00
|
|
|
|
2014-02-17 07:58:51 +00:00
|
|
|
let cfg = config.services.xserver.synaptics;
|
|
|
|
tapConfig = if cfg.tapButtons then enabledTapConfig else disabledTapConfig;
|
|
|
|
enabledTapConfig = ''
|
|
|
|
Option "MaxTapTime" "180"
|
|
|
|
Option "MaxTapMove" "220"
|
2014-11-04 03:19:53 +00:00
|
|
|
Option "TapButton1" "${builtins.elemAt cfg.fingersMap 0}"
|
|
|
|
Option "TapButton2" "${builtins.elemAt cfg.fingersMap 1}"
|
|
|
|
Option "TapButton3" "${builtins.elemAt cfg.fingersMap 2}"
|
2014-02-17 07:58:51 +00:00
|
|
|
'';
|
|
|
|
disabledTapConfig = ''
|
|
|
|
Option "MaxTapTime" "0"
|
|
|
|
Option "MaxTapMove" "0"
|
|
|
|
Option "TapButton1" "0"
|
|
|
|
Option "TapButton2" "0"
|
|
|
|
Option "TapButton3" "0"
|
|
|
|
'';
|
2015-09-18 15:03:17 +01:00
|
|
|
pkg = pkgs.xorg.xf86inputsynaptics;
|
2017-01-03 19:23:24 +00:00
|
|
|
etcFile = "X11/xorg.conf.d/70-synaptics.conf";
|
2014-02-17 07:58:51 +00:00
|
|
|
in {
|
2009-09-10 13:37:33 +01:00
|
|
|
|
|
|
|
options = {
|
|
|
|
|
|
|
|
services.xserver.synaptics = {
|
2011-09-14 19:20:50 +01:00
|
|
|
|
2009-09-10 13:37:33 +01:00
|
|
|
enable = mkOption {
|
2014-10-31 09:38:58 +00:00
|
|
|
type = types.bool;
|
2009-09-10 13:37:33 +01:00
|
|
|
default = false;
|
2017-08-31 01:32:45 +01:00
|
|
|
description = "Whether to enable touchpad support. Deprecated: Consider services.xserver.libinput.enable.";
|
2009-09-10 13:37:33 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
dev = mkOption {
|
2014-10-31 09:38:58 +00:00
|
|
|
type = types.nullOr types.str;
|
2010-08-10 15:13:57 +01:00
|
|
|
default = null;
|
2012-01-10 18:40:02 +00:00
|
|
|
example = "/dev/input/event0";
|
2011-09-14 19:20:50 +01:00
|
|
|
description =
|
2010-08-10 15:13:57 +01:00
|
|
|
''
|
|
|
|
Path for touchpad device. Set to null to apply to any
|
|
|
|
auto-detected touchpad.
|
|
|
|
'';
|
2009-09-10 13:37:33 +01:00
|
|
|
};
|
|
|
|
|
2012-06-16 12:13:48 +01:00
|
|
|
accelFactor = mkOption {
|
2019-08-08 21:48:27 +01:00
|
|
|
type = types.nullOr types.str;
|
2012-06-16 12:13:48 +01:00
|
|
|
default = "0.001";
|
|
|
|
description = "Cursor acceleration (how fast speed increases from minSpeed to maxSpeed).";
|
|
|
|
};
|
|
|
|
|
2009-09-10 13:37:33 +01:00
|
|
|
minSpeed = mkOption {
|
2019-08-08 21:48:27 +01:00
|
|
|
type = types.nullOr types.str;
|
2010-08-02 20:06:42 +01:00
|
|
|
default = "0.6";
|
2009-09-10 13:37:33 +01:00
|
|
|
description = "Cursor speed factor for precision finger motion.";
|
|
|
|
};
|
|
|
|
|
|
|
|
maxSpeed = mkOption {
|
2019-08-08 21:48:27 +01:00
|
|
|
type = types.nullOr types.str;
|
2010-08-02 20:06:42 +01:00
|
|
|
default = "1.0";
|
2009-09-10 13:37:33 +01:00
|
|
|
description = "Cursor speed factor for highest-speed finger motion.";
|
|
|
|
};
|
|
|
|
|
2015-09-18 10:42:09 +01:00
|
|
|
scrollDelta = mkOption {
|
|
|
|
type = types.nullOr types.int;
|
|
|
|
default = null;
|
|
|
|
example = 75;
|
|
|
|
description = "Move distance of the finger for a scroll event.";
|
|
|
|
};
|
|
|
|
|
2009-09-10 13:37:33 +01:00
|
|
|
twoFingerScroll = mkOption {
|
2014-10-31 09:38:58 +00:00
|
|
|
type = types.bool;
|
2009-09-10 13:37:33 +01:00
|
|
|
default = false;
|
2015-07-07 20:56:13 +01:00
|
|
|
description = "Whether to enable two-finger drag-scrolling. Overridden by horizTwoFingerScroll and vertTwoFingerScroll.";
|
|
|
|
};
|
|
|
|
|
|
|
|
horizTwoFingerScroll = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = cfg.twoFingerScroll;
|
|
|
|
description = "Whether to enable horizontal two-finger drag-scrolling.";
|
|
|
|
};
|
|
|
|
|
|
|
|
vertTwoFingerScroll = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = cfg.twoFingerScroll;
|
|
|
|
description = "Whether to enable vertical two-finger drag-scrolling.";
|
|
|
|
};
|
|
|
|
|
|
|
|
horizEdgeScroll = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = ! cfg.horizTwoFingerScroll;
|
|
|
|
description = "Whether to enable horizontal edge drag-scrolling.";
|
2009-09-10 13:37:33 +01:00
|
|
|
};
|
|
|
|
|
2010-08-02 20:06:42 +01:00
|
|
|
vertEdgeScroll = mkOption {
|
2014-10-31 09:38:58 +00:00
|
|
|
type = types.bool;
|
2015-07-07 20:56:13 +01:00
|
|
|
default = ! cfg.vertTwoFingerScroll;
|
2010-08-02 20:06:42 +01:00
|
|
|
description = "Whether to enable vertical edge drag-scrolling.";
|
|
|
|
};
|
|
|
|
|
2012-01-13 22:23:18 +00:00
|
|
|
tapButtons = mkOption {
|
2014-10-31 09:38:58 +00:00
|
|
|
type = types.bool;
|
2012-01-13 22:23:18 +00:00
|
|
|
default = true;
|
|
|
|
description = "Whether to enable tap buttons.";
|
|
|
|
};
|
|
|
|
|
2013-11-03 09:00:49 +00:00
|
|
|
buttonsMap = mkOption {
|
2014-10-31 09:38:58 +00:00
|
|
|
type = types.listOf types.int;
|
2013-11-03 09:00:49 +00:00
|
|
|
default = [1 2 3];
|
|
|
|
example = [1 3 2];
|
|
|
|
description = "Remap touchpad buttons.";
|
|
|
|
apply = map toString;
|
|
|
|
};
|
|
|
|
|
2014-10-31 09:45:11 +00:00
|
|
|
fingersMap = mkOption {
|
|
|
|
type = types.listOf types.int;
|
|
|
|
default = [1 2 3];
|
|
|
|
example = [1 3 2];
|
|
|
|
description = "Remap several-fingers taps.";
|
|
|
|
apply = map toString;
|
|
|
|
};
|
|
|
|
|
2012-01-13 22:23:18 +00:00
|
|
|
palmDetect = mkOption {
|
2014-10-31 09:38:58 +00:00
|
|
|
type = types.bool;
|
2012-01-14 09:40:08 +00:00
|
|
|
default = false;
|
2012-01-13 22:23:18 +00:00
|
|
|
description = "Whether to enable palm detection (hardware support required)";
|
|
|
|
};
|
|
|
|
|
2015-09-18 10:26:45 +01:00
|
|
|
palmMinWidth = mkOption {
|
|
|
|
type = types.nullOr types.int;
|
|
|
|
default = null;
|
|
|
|
example = 5;
|
|
|
|
description = "Minimum finger width at which touch is considered a palm";
|
|
|
|
};
|
|
|
|
|
|
|
|
palmMinZ = mkOption {
|
|
|
|
type = types.nullOr types.int;
|
|
|
|
default = null;
|
|
|
|
example = 20;
|
|
|
|
description = "Minimum finger pressure at which touch is considered a palm";
|
|
|
|
};
|
|
|
|
|
2012-04-19 09:29:22 +01:00
|
|
|
horizontalScroll = mkOption {
|
2014-10-31 09:38:58 +00:00
|
|
|
type = types.bool;
|
2012-04-19 09:29:22 +01:00
|
|
|
default = true;
|
|
|
|
description = "Whether to enable horizontal scrolling (on touchpad)";
|
|
|
|
};
|
|
|
|
|
2012-01-10 18:40:02 +00:00
|
|
|
additionalOptions = mkOption {
|
2014-10-31 09:38:58 +00:00
|
|
|
type = types.str;
|
2012-01-10 18:40:02 +00:00
|
|
|
default = "";
|
|
|
|
example = ''
|
|
|
|
Option "RTCornerButton" "2"
|
|
|
|
Option "RBCornerButton" "3"
|
2013-10-29 16:29:37 +00:00
|
|
|
'';
|
2012-01-10 18:40:02 +00:00
|
|
|
description = ''
|
|
|
|
Additional options for synaptics touchpad driver.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2009-09-10 13:37:33 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
|
2016-04-06 09:45:24 +01:00
|
|
|
services.xserver.modules = [ pkg.out ];
|
2009-09-10 13:37:33 +01:00
|
|
|
|
2019-08-13 22:52:01 +01:00
|
|
|
environment.etc.${etcFile}.source =
|
2017-01-03 19:23:24 +00:00
|
|
|
"${pkg.out}/share/X11/xorg.conf.d/70-synaptics.conf";
|
2015-09-18 15:03:17 +01:00
|
|
|
|
|
|
|
environment.systemPackages = [ pkg ];
|
2013-05-09 14:01:16 +01:00
|
|
|
|
2009-09-10 13:37:33 +01:00
|
|
|
services.xserver.config =
|
|
|
|
''
|
2010-08-10 15:13:57 +01:00
|
|
|
# Automatically enable the synaptics driver for all touchpads.
|
|
|
|
Section "InputClass"
|
2010-09-03 20:10:45 +01:00
|
|
|
Identifier "synaptics touchpad catchall"
|
2010-08-10 15:13:57 +01:00
|
|
|
MatchIsTouchpad "on"
|
|
|
|
${optionalString (cfg.dev != null) ''MatchDevicePath "${cfg.dev}"''}
|
2010-09-03 20:10:45 +01:00
|
|
|
Driver "synaptics"
|
2014-08-04 01:46:35 +01:00
|
|
|
${optionalString (cfg.minSpeed != null) ''Option "MinSpeed" "${cfg.minSpeed}"''}
|
|
|
|
${optionalString (cfg.maxSpeed != null) ''Option "MaxSpeed" "${cfg.maxSpeed}"''}
|
|
|
|
${optionalString (cfg.accelFactor != null) ''Option "AccelFactor" "${cfg.accelFactor}"''}
|
2014-02-17 07:58:51 +00:00
|
|
|
${optionalString cfg.tapButtons tapConfig}
|
2013-11-03 09:00:49 +00:00
|
|
|
Option "ClickFinger1" "${builtins.elemAt cfg.buttonsMap 0}"
|
|
|
|
Option "ClickFinger2" "${builtins.elemAt cfg.buttonsMap 1}"
|
|
|
|
Option "ClickFinger3" "${builtins.elemAt cfg.buttonsMap 2}"
|
2015-07-07 20:56:13 +01:00
|
|
|
Option "VertTwoFingerScroll" "${if cfg.vertTwoFingerScroll then "1" else "0"}"
|
|
|
|
Option "HorizTwoFingerScroll" "${if cfg.horizTwoFingerScroll then "1" else "0"}"
|
2010-08-02 20:06:42 +01:00
|
|
|
Option "VertEdgeScroll" "${if cfg.vertEdgeScroll then "1" else "0"}"
|
2015-07-07 20:56:13 +01:00
|
|
|
Option "HorizEdgeScroll" "${if cfg.horizEdgeScroll then "1" else "0"}"
|
2015-09-18 10:26:45 +01:00
|
|
|
${optionalString cfg.palmDetect ''Option "PalmDetect" "1"''}
|
|
|
|
${optionalString (cfg.palmMinWidth != null) ''Option "PalmMinWidth" "${toString cfg.palmMinWidth}"''}
|
|
|
|
${optionalString (cfg.palmMinZ != null) ''Option "PalmMinZ" "${toString cfg.palmMinZ}"''}
|
2015-09-18 10:42:09 +01:00
|
|
|
${optionalString (cfg.scrollDelta != null) ''Option "VertScrollDelta" "${toString cfg.scrollDelta}"''}
|
|
|
|
${if !cfg.horizontalScroll then ''Option "HorizScrollDelta" "0"''
|
|
|
|
else (optionalString (cfg.scrollDelta != null) ''Option "HorizScrollDelta" "${toString cfg.scrollDelta}"'')}
|
2012-01-10 18:40:02 +00:00
|
|
|
${cfg.additionalOptions}
|
2009-09-10 13:37:33 +01:00
|
|
|
EndSection
|
|
|
|
'';
|
|
|
|
|
2016-08-03 07:15:18 +01:00
|
|
|
assertions = [
|
|
|
|
{
|
|
|
|
assertion = !config.services.xserver.libinput.enable;
|
|
|
|
message = "Synaptics and libinput are incompatible, you cannot enable both (in services.xserver).";
|
|
|
|
}
|
|
|
|
];
|
|
|
|
|
2009-09-10 13:37:33 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|