2015-09-18 16:29:10 +01:00
|
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
|
|
let cfg = config.services.xserver.libinput;
|
2016-01-22 10:46:02 +00:00
|
|
|
|
xorgBool = v: if v then "on" else "off";
|
2015-09-18 16:29:10 +01:00
|
|
|
|
in {
|
|
|
|
|
|
|
|
|
|
options = {
|
|
|
|
|
|
|
|
|
|
services.xserver.libinput = {
|
|
|
|
|
|
2016-02-27 06:24:47 +00:00
|
|
|
|
enable = mkEnableOption "libinput";
|
2015-09-18 16:29:10 +01:00
|
|
|
|
|
|
|
|
|
dev = mkOption {
|
|
|
|
|
type = types.nullOr types.str;
|
|
|
|
|
default = null;
|
|
|
|
|
example = "/dev/input/event0";
|
|
|
|
|
description =
|
|
|
|
|
''
|
|
|
|
|
Path for touchpad device. Set to null to apply to any
|
|
|
|
|
auto-detected touchpad.
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
2016-01-22 10:46:02 +00:00
|
|
|
|
accelProfile = mkOption {
|
|
|
|
|
type = types.enum [ "flat" "adaptive" ];
|
2016-08-08 12:36:30 +01:00
|
|
|
|
default = "adaptive";
|
|
|
|
|
example = "flat";
|
2016-01-22 10:46:02 +00:00
|
|
|
|
description =
|
|
|
|
|
''
|
2016-08-08 12:36:30 +01:00
|
|
|
|
Sets the pointer acceleration profile to the given profile.
|
|
|
|
|
Permitted values are adaptive, flat.
|
|
|
|
|
Not all devices support this option or all profiles.
|
|
|
|
|
If a profile is unsupported, the default profile for this is used.
|
|
|
|
|
<literal>flat</literal>: Pointer motion is accelerated by a constant
|
|
|
|
|
(device-specific) factor, depending on the current speed.
|
|
|
|
|
<literal>adaptive</literal>: Pointer acceleration depends on the input speed.
|
|
|
|
|
This is the default profile for most devices.
|
2016-01-22 10:46:02 +00:00
|
|
|
|
'';
|
2016-08-08 12:36:30 +01:00
|
|
|
|
};
|
|
|
|
|
|
2015-09-18 16:29:10 +01:00
|
|
|
|
accelSpeed = mkOption {
|
2019-08-08 21:48:27 +01:00
|
|
|
|
type = types.nullOr types.str;
|
2015-09-18 16:29:10 +01:00
|
|
|
|
default = null;
|
|
|
|
|
description = "Cursor acceleration (how fast speed increases from minSpeed to maxSpeed).";
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
buttonMapping = mkOption {
|
2019-08-08 21:48:27 +01:00
|
|
|
|
type = types.nullOr types.str;
|
2015-09-18 16:29:10 +01:00
|
|
|
|
default = null;
|
|
|
|
|
description =
|
|
|
|
|
''
|
|
|
|
|
Sets the logical button mapping for this device, see XSetPointerMapping(3). The string must
|
|
|
|
|
be a space-separated list of button mappings in the order of the logical buttons on the
|
|
|
|
|
device, starting with button 1. The default mapping is "1 2 3 ... 32". A mapping of 0 deac‐
|
|
|
|
|
tivates the button. Multiple buttons can have the same mapping. Invalid mapping strings are
|
|
|
|
|
discarded and the default mapping is used for all buttons. Buttons not specified in the
|
|
|
|
|
user's mapping use the default mapping. See section BUTTON MAPPING for more details.
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
calibrationMatrix = mkOption {
|
2019-08-08 21:48:27 +01:00
|
|
|
|
type = types.nullOr types.str;
|
2015-09-18 16:29:10 +01:00
|
|
|
|
default = null;
|
|
|
|
|
description =
|
|
|
|
|
''
|
|
|
|
|
A string of 9 space-separated floating point numbers. Sets the calibration matrix to the
|
|
|
|
|
3x3 matrix where the first row is (abc), the second row is (def) and the third row is (ghi).
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
2016-01-22 10:46:02 +00:00
|
|
|
|
clickMethod = mkOption {
|
|
|
|
|
type = types.nullOr (types.enum [ "none" "buttonareas" "clickfinger" ]);
|
|
|
|
|
default = null;
|
|
|
|
|
description =
|
|
|
|
|
''
|
2017-10-09 20:07:19 +01:00
|
|
|
|
Enables a click method. Permitted values are <literal>none</literal>,
|
|
|
|
|
<literal>buttonareas</literal>, <literal>clickfinger</literal>.
|
2016-01-22 10:46:02 +00:00
|
|
|
|
Not all devices support all methods, if an option is unsupported,
|
2017-10-09 20:07:19 +01:00
|
|
|
|
the default click method for this device is used.
|
2016-01-22 10:46:02 +00:00
|
|
|
|
'';
|
|
|
|
|
};
|
2017-10-09 20:07:19 +01:00
|
|
|
|
|
2016-01-22 10:46:02 +00:00
|
|
|
|
leftHanded = mkOption {
|
2016-01-13 08:27:02 +00:00
|
|
|
|
type = types.bool;
|
|
|
|
|
default = false;
|
2016-01-22 10:46:02 +00:00
|
|
|
|
description = "Enables left-handed button orientation, i.e. swapping left and right buttons.";
|
2016-01-13 08:27:02 +00:00
|
|
|
|
};
|
|
|
|
|
|
2016-01-22 10:46:02 +00:00
|
|
|
|
middleEmulation = mkOption {
|
2015-09-18 16:29:10 +01:00
|
|
|
|
type = types.bool;
|
|
|
|
|
default = true;
|
|
|
|
|
description =
|
|
|
|
|
''
|
2016-01-22 10:46:02 +00:00
|
|
|
|
Enables middle button emulation. When enabled, pressing the left and right buttons
|
|
|
|
|
simultaneously produces a middle mouse button click.
|
|
|
|
|
'';
|
|
|
|
|
};
|
2017-10-09 20:07:19 +01:00
|
|
|
|
|
2016-01-22 10:46:02 +00:00
|
|
|
|
naturalScrolling = mkOption {
|
|
|
|
|
type = types.bool;
|
|
|
|
|
default = false;
|
|
|
|
|
description = "Enables or disables natural scrolling behavior.";
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
scrollButton = mkOption {
|
|
|
|
|
type = types.nullOr types.int;
|
|
|
|
|
default = null;
|
|
|
|
|
example = 1;
|
|
|
|
|
description =
|
|
|
|
|
''
|
|
|
|
|
Designates a button as scroll button. If the ScrollMethod is button and the button is logically
|
|
|
|
|
held down, x/y axis movement is converted into scroll events.
|
2015-09-18 16:29:10 +01:00
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
2016-01-13 08:27:02 +00:00
|
|
|
|
scrollMethod = mkOption {
|
2018-06-28 12:15:00 +01:00
|
|
|
|
type = types.enum [ "twofinger" "edge" "button" "none" ];
|
2016-01-13 08:27:02 +00:00
|
|
|
|
default = "twofinger";
|
|
|
|
|
example = "edge";
|
|
|
|
|
description =
|
|
|
|
|
''
|
2017-10-09 20:07:19 +01:00
|
|
|
|
Specify the scrolling method: <literal>twofinger</literal>, <literal>edge</literal>,
|
2019-10-21 08:16:01 +01:00
|
|
|
|
<literal>button</literal>, or <literal>none</literal>
|
2016-01-13 08:27:02 +00:00
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
2016-01-22 10:46:02 +00:00
|
|
|
|
horizontalScrolling = mkOption {
|
2016-01-13 08:27:02 +00:00
|
|
|
|
type = types.bool;
|
|
|
|
|
default = true;
|
|
|
|
|
description =
|
|
|
|
|
''
|
2016-01-22 10:46:02 +00:00
|
|
|
|
Disables horizontal scrolling. When disabled, this driver will discard any horizontal scroll
|
|
|
|
|
events from libinput. Note that this does not disable horizontal scrolling, it merely
|
|
|
|
|
discards the horizontal axis from any scroll events.
|
2016-01-13 08:27:02 +00:00
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
2016-01-22 10:46:02 +00:00
|
|
|
|
sendEventsMode = mkOption {
|
|
|
|
|
type = types.enum [ "disabled" "enabled" "disabled-on-external-mouse" ];
|
|
|
|
|
default = "enabled";
|
|
|
|
|
example = "disabled";
|
|
|
|
|
description =
|
|
|
|
|
''
|
2017-10-09 20:07:19 +01:00
|
|
|
|
Sets the send events mode to <literal>disabled</literal>, <literal>enabled</literal>,
|
|
|
|
|
or <literal>disabled-on-external-mouse</literal>
|
2016-01-22 10:46:02 +00:00
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
tapping = mkOption {
|
|
|
|
|
type = types.bool;
|
|
|
|
|
default = true;
|
|
|
|
|
description =
|
|
|
|
|
''
|
|
|
|
|
Enables or disables tap-to-click behavior.
|
|
|
|
|
'';
|
|
|
|
|
};
|
2016-01-13 08:27:02 +00:00
|
|
|
|
|
2015-09-18 16:29:10 +01:00
|
|
|
|
tappingDragLock = mkOption {
|
|
|
|
|
type = types.bool;
|
|
|
|
|
default = true;
|
|
|
|
|
description =
|
|
|
|
|
''
|
|
|
|
|
Enables or disables drag lock during tapping behavior. When enabled, a finger up during tap-
|
|
|
|
|
and-drag will not immediately release the button. If the finger is set down again within the
|
|
|
|
|
timeout, the draging process continues.
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
2016-01-22 10:46:02 +00:00
|
|
|
|
disableWhileTyping = mkOption {
|
|
|
|
|
type = types.bool;
|
2017-12-30 22:02:16 +00:00
|
|
|
|
default = false;
|
2016-01-22 10:46:02 +00:00
|
|
|
|
description =
|
|
|
|
|
''
|
|
|
|
|
Disable input method while typing.
|
|
|
|
|
'';
|
|
|
|
|
};
|
2015-09-18 16:29:10 +01:00
|
|
|
|
|
|
|
|
|
additionalOptions = mkOption {
|
2019-07-10 17:21:22 +01:00
|
|
|
|
type = types.lines;
|
2015-09-18 16:29:10 +01:00
|
|
|
|
default = "";
|
2016-01-22 10:46:02 +00:00
|
|
|
|
example =
|
|
|
|
|
''
|
|
|
|
|
Option "DragLockButtons" "L1 B1 L2 B2"
|
2015-09-18 16:29:10 +01:00
|
|
|
|
'';
|
2016-01-22 10:46:02 +00:00
|
|
|
|
description = "Additional options for libinput touchpad driver.";
|
2015-09-18 16:29:10 +01:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
|
|
|
|
|
|
services.xserver.modules = [ pkgs.xorg.xf86inputlibinput ];
|
|
|
|
|
|
|
|
|
|
environment.systemPackages = [ pkgs.xorg.xf86inputlibinput ];
|
|
|
|
|
|
2017-11-23 23:25:54 +00:00
|
|
|
|
environment.etc = [
|
|
|
|
|
(let cfgPath = "X11/xorg.conf.d/40-libinput.conf"; in {
|
|
|
|
|
source = pkgs.xorg.xf86inputlibinput.out + "/share/" + cfgPath;
|
|
|
|
|
target = cfgPath;
|
|
|
|
|
})
|
|
|
|
|
];
|
|
|
|
|
|
2018-08-30 14:27:26 +01:00
|
|
|
|
services.udev.packages = [ pkgs.libinput.out ];
|
2016-07-18 13:27:08 +01:00
|
|
|
|
|
2015-09-18 16:29:10 +01:00
|
|
|
|
services.xserver.config =
|
|
|
|
|
''
|
|
|
|
|
# Automatically enable the libinput driver for all touchpads.
|
|
|
|
|
Section "InputClass"
|
|
|
|
|
Identifier "libinputConfiguration"
|
|
|
|
|
MatchIsTouchpad "on"
|
|
|
|
|
${optionalString (cfg.dev != null) ''MatchDevicePath "${cfg.dev}"''}
|
|
|
|
|
Driver "libinput"
|
2016-01-22 10:46:02 +00:00
|
|
|
|
Option "AccelProfile" "${cfg.accelProfile}"
|
2015-09-18 16:29:10 +01:00
|
|
|
|
${optionalString (cfg.accelSpeed != null) ''Option "AccelSpeed" "${cfg.accelSpeed}"''}
|
|
|
|
|
${optionalString (cfg.buttonMapping != null) ''Option "ButtonMapping" "${cfg.buttonMapping}"''}
|
|
|
|
|
${optionalString (cfg.calibrationMatrix != null) ''Option "CalibrationMatrix" "${cfg.calibrationMatrix}"''}
|
2016-01-22 10:46:02 +00:00
|
|
|
|
${optionalString (cfg.clickMethod != null) ''Option "ClickMethod" "${cfg.clickMethod}"''}
|
|
|
|
|
Option "LeftHanded" "${xorgBool cfg.leftHanded}"
|
|
|
|
|
Option "MiddleEmulation" "${xorgBool cfg.middleEmulation}"
|
|
|
|
|
Option "NaturalScrolling" "${xorgBool cfg.naturalScrolling}"
|
2016-08-08 12:36:30 +01:00
|
|
|
|
${optionalString (cfg.scrollButton != null) ''Option "ScrollButton" "${toString cfg.scrollButton}"''}
|
2016-01-13 08:27:02 +00:00
|
|
|
|
Option "ScrollMethod" "${cfg.scrollMethod}"
|
2016-01-22 10:46:02 +00:00
|
|
|
|
Option "HorizontalScrolling" "${xorgBool cfg.horizontalScrolling}"
|
|
|
|
|
Option "SendEventsMode" "${cfg.sendEventsMode}"
|
|
|
|
|
Option "Tapping" "${xorgBool cfg.tapping}"
|
|
|
|
|
Option "TappingDragLock" "${xorgBool cfg.tappingDragLock}"
|
|
|
|
|
Option "DisableWhileTyping" "${xorgBool cfg.disableWhileTyping}"
|
2015-09-18 16:29:10 +01:00
|
|
|
|
${cfg.additionalOptions}
|
|
|
|
|
EndSection
|
|
|
|
|
'';
|
|
|
|
|
|
2016-08-03 07:15:18 +01:00
|
|
|
|
assertions = [
|
|
|
|
|
# already present in synaptics.nix
|
|
|
|
|
/* {
|
|
|
|
|
assertion = !config.services.xserver.synaptics.enable;
|
|
|
|
|
message = "Synaptics and libinput are incompatible, you cannot enable both (in services.xserver).";
|
|
|
|
|
} */
|
|
|
|
|
];
|
|
|
|
|
|
2015-09-18 16:29:10 +01:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|