2014-04-14 16:26:48 +02:00
|
|
|
{ config, lib, pkgs, ... }:
|
2009-09-10 14:37:33 +02:00
|
|
|
|
2014-04-14 16:26:48 +02:00
|
|
|
with lib;
|
2009-09-10 14:37:33 +02:00
|
|
|
|
2014-02-17 08:58:51 +01:00
|
|
|
let cfg = config.services.xserver.synaptics;
|
|
|
|
tapConfig = if cfg.tapButtons then enabledTapConfig else disabledTapConfig;
|
|
|
|
enabledTapConfig = ''
|
|
|
|
Option "MaxTapTime" "180"
|
|
|
|
Option "MaxTapMove" "220"
|
|
|
|
Option "TapButton1" "${builtins.elemAt cfg.buttonsMap 0}"
|
|
|
|
Option "TapButton2" "${builtins.elemAt cfg.buttonsMap 1}"
|
|
|
|
Option "TapButton3" "${builtins.elemAt cfg.buttonsMap 2}"
|
|
|
|
'';
|
|
|
|
disabledTapConfig = ''
|
|
|
|
Option "MaxTapTime" "0"
|
|
|
|
Option "MaxTapMove" "0"
|
|
|
|
Option "TapButton1" "0"
|
|
|
|
Option "TapButton2" "0"
|
|
|
|
Option "TapButton3" "0"
|
|
|
|
'';
|
|
|
|
in {
|
2009-09-10 14:37:33 +02:00
|
|
|
|
|
|
|
options = {
|
|
|
|
|
|
|
|
services.xserver.synaptics = {
|
2011-09-14 20:20:50 +02:00
|
|
|
|
2009-09-10 14:37:33 +02:00
|
|
|
enable = mkOption {
|
|
|
|
default = false;
|
|
|
|
example = true;
|
|
|
|
description = "Whether to enable touchpad support.";
|
|
|
|
};
|
|
|
|
|
|
|
|
dev = mkOption {
|
2010-08-10 16:13:57 +02:00
|
|
|
default = null;
|
2012-01-10 19:40:02 +01:00
|
|
|
example = "/dev/input/event0";
|
2011-09-14 20:20:50 +02:00
|
|
|
description =
|
2010-08-10 16:13:57 +02:00
|
|
|
''
|
|
|
|
Path for touchpad device. Set to null to apply to any
|
|
|
|
auto-detected touchpad.
|
|
|
|
'';
|
2009-09-10 14:37:33 +02:00
|
|
|
};
|
|
|
|
|
2012-06-16 13:13:48 +02:00
|
|
|
accelFactor = mkOption {
|
2014-08-04 02:46:35 +02:00
|
|
|
type = types.nullOr types.string;
|
2012-06-16 13:13:48 +02:00
|
|
|
default = "0.001";
|
|
|
|
description = "Cursor acceleration (how fast speed increases from minSpeed to maxSpeed).";
|
|
|
|
};
|
|
|
|
|
2009-09-10 14:37:33 +02:00
|
|
|
minSpeed = mkOption {
|
2014-08-04 02:46:35 +02:00
|
|
|
type = types.nullOr types.string;
|
2010-08-02 21:06:42 +02:00
|
|
|
default = "0.6";
|
2009-09-10 14:37:33 +02:00
|
|
|
description = "Cursor speed factor for precision finger motion.";
|
|
|
|
};
|
|
|
|
|
|
|
|
maxSpeed = mkOption {
|
2014-08-04 02:46:35 +02:00
|
|
|
type = types.nullOr types.string;
|
2010-08-02 21:06:42 +02:00
|
|
|
default = "1.0";
|
2009-09-10 14:37:33 +02:00
|
|
|
description = "Cursor speed factor for highest-speed finger motion.";
|
|
|
|
};
|
|
|
|
|
|
|
|
twoFingerScroll = mkOption {
|
|
|
|
default = false;
|
|
|
|
description = "Whether to enable two-finger drag-scrolling.";
|
|
|
|
};
|
|
|
|
|
2010-08-02 21:06:42 +02:00
|
|
|
vertEdgeScroll = mkOption {
|
2011-08-11 00:14:46 +02:00
|
|
|
default = ! cfg.twoFingerScroll;
|
2010-08-02 21:06:42 +02:00
|
|
|
description = "Whether to enable vertical edge drag-scrolling.";
|
|
|
|
};
|
|
|
|
|
2012-01-13 23:23:18 +01:00
|
|
|
tapButtons = mkOption {
|
|
|
|
default = true;
|
2012-01-14 13:24:41 +01:00
|
|
|
example = false;
|
2012-01-13 23:23:18 +01:00
|
|
|
description = "Whether to enable tap buttons.";
|
|
|
|
};
|
|
|
|
|
2013-11-03 10:00:49 +01:00
|
|
|
buttonsMap = mkOption {
|
|
|
|
default = [1 2 3];
|
|
|
|
example = [1 3 2];
|
|
|
|
description = "Remap touchpad buttons.";
|
|
|
|
apply = map toString;
|
|
|
|
};
|
|
|
|
|
2012-01-13 23:23:18 +01:00
|
|
|
palmDetect = mkOption {
|
2012-01-14 10:40:08 +01:00
|
|
|
default = false;
|
2012-01-14 13:24:41 +01:00
|
|
|
example = true;
|
2012-01-13 23:23:18 +01:00
|
|
|
description = "Whether to enable palm detection (hardware support required)";
|
|
|
|
};
|
|
|
|
|
2012-04-19 10:29:22 +02:00
|
|
|
horizontalScroll = mkOption {
|
|
|
|
default = true;
|
|
|
|
example = false;
|
|
|
|
description = "Whether to enable horizontal scrolling (on touchpad)";
|
|
|
|
};
|
|
|
|
|
2012-01-10 19:40:02 +01:00
|
|
|
additionalOptions = mkOption {
|
|
|
|
default = "";
|
|
|
|
example = ''
|
|
|
|
Option "RTCornerButton" "2"
|
|
|
|
Option "RBCornerButton" "3"
|
2013-10-29 17:29:37 +01:00
|
|
|
'';
|
2012-01-10 19:40:02 +01:00
|
|
|
description = ''
|
|
|
|
Additional options for synaptics touchpad driver.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2009-09-10 14:37:33 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
|
|
|
|
services.xserver.modules = [ pkgs.xorg.xf86inputsynaptics ];
|
|
|
|
|
2013-05-09 15:01:16 +02:00
|
|
|
environment.systemPackages = [ pkgs.xorg.xf86inputsynaptics ];
|
|
|
|
|
2009-09-10 14:37:33 +02:00
|
|
|
services.xserver.config =
|
|
|
|
''
|
2010-08-10 16:13:57 +02:00
|
|
|
# Automatically enable the synaptics driver for all touchpads.
|
|
|
|
Section "InputClass"
|
2010-09-03 21:10:45 +02:00
|
|
|
Identifier "synaptics touchpad catchall"
|
2010-08-10 16:13:57 +02:00
|
|
|
MatchIsTouchpad "on"
|
|
|
|
${optionalString (cfg.dev != null) ''MatchDevicePath "${cfg.dev}"''}
|
2010-09-03 21:10:45 +02:00
|
|
|
Driver "synaptics"
|
2014-08-04 02:46:35 +02: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 08:58:51 +01:00
|
|
|
${optionalString cfg.tapButtons tapConfig}
|
2013-11-03 10:00:49 +01:00
|
|
|
Option "ClickFinger1" "${builtins.elemAt cfg.buttonsMap 0}"
|
|
|
|
Option "ClickFinger2" "${builtins.elemAt cfg.buttonsMap 1}"
|
|
|
|
Option "ClickFinger3" "${builtins.elemAt cfg.buttonsMap 2}"
|
2009-09-10 14:37:33 +02:00
|
|
|
Option "VertTwoFingerScroll" "${if cfg.twoFingerScroll then "1" else "0"}"
|
|
|
|
Option "HorizTwoFingerScroll" "${if cfg.twoFingerScroll then "1" else "0"}"
|
2010-08-02 21:06:42 +02:00
|
|
|
Option "VertEdgeScroll" "${if cfg.vertEdgeScroll then "1" else "0"}"
|
2012-01-13 23:23:18 +01:00
|
|
|
${if cfg.palmDetect then ''Option "PalmDetect" "1"'' else ""}
|
2012-04-19 10:29:22 +02:00
|
|
|
${if cfg.horizontalScroll then "" else ''Option "HorizScrollDelta" "0"''}
|
2012-01-10 19:40:02 +01:00
|
|
|
${cfg.additionalOptions}
|
2009-09-10 14:37:33 +02:00
|
|
|
EndSection
|
|
|
|
'';
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|