2020-04-24 23:36:52 +00:00
|
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
|
|
let cfg = config.services.xserver.libinput;
|
|
|
|
|
|
2021-02-05 17:12:51 +00:00
|
|
|
|
xorgBool = v: if v then "on" else "off";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
2021-02-05 17:12:51 +00:00
|
|
|
|
mkConfigForDevice = deviceType: {
|
2020-04-24 23:36:52 +00:00
|
|
|
|
dev = mkOption {
|
|
|
|
|
type = types.nullOr types.str;
|
|
|
|
|
default = null;
|
|
|
|
|
example = "/dev/input/event0";
|
|
|
|
|
description =
|
2022-08-12 12:06:08 +00:00
|
|
|
|
lib.mdDoc ''
|
|
|
|
|
Path for ${deviceType} device. Set to `null` to apply to any
|
2021-02-05 17:12:51 +00:00
|
|
|
|
auto-detected ${deviceType}.
|
2020-04-24 23:36:52 +00:00
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
accelProfile = mkOption {
|
|
|
|
|
type = types.enum [ "flat" "adaptive" ];
|
|
|
|
|
default = "adaptive";
|
|
|
|
|
example = "flat";
|
|
|
|
|
description =
|
2022-08-12 12:06:08 +00:00
|
|
|
|
lib.mdDoc ''
|
2021-12-06 16:07:01 +00:00
|
|
|
|
Sets the pointer acceleration profile to the given profile.
|
2022-08-12 12:06:08 +00:00
|
|
|
|
Permitted values are `adaptive`, `flat`.
|
2020-04-24 23:36:52 +00:00
|
|
|
|
Not all devices support this option or all profiles.
|
|
|
|
|
If a profile is unsupported, the default profile for this is used.
|
2022-08-12 12:06:08 +00:00
|
|
|
|
`flat`: Pointer motion is accelerated by a constant
|
2020-04-24 23:36:52 +00:00
|
|
|
|
(device-specific) factor, depending on the current speed.
|
2022-08-12 12:06:08 +00:00
|
|
|
|
`adaptive`: Pointer acceleration depends on the input speed.
|
2020-04-24 23:36:52 +00:00
|
|
|
|
This is the default profile for most devices.
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
accelSpeed = mkOption {
|
|
|
|
|
type = types.nullOr types.str;
|
|
|
|
|
default = null;
|
2021-12-06 16:07:01 +00:00
|
|
|
|
example = "-0.5";
|
2022-08-12 12:06:08 +00:00
|
|
|
|
description = lib.mdDoc "Cursor acceleration (how fast speed increases from minSpeed to maxSpeed).";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
buttonMapping = mkOption {
|
|
|
|
|
type = types.nullOr types.str;
|
|
|
|
|
default = null;
|
2021-12-06 16:07:01 +00:00
|
|
|
|
example = "1 6 3 4 5 0 7";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
description =
|
2022-08-12 12:06:08 +00:00
|
|
|
|
lib.mdDoc ''
|
2020-04-24 23:36:52 +00:00
|
|
|
|
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 {
|
|
|
|
|
type = types.nullOr types.str;
|
|
|
|
|
default = null;
|
2021-12-06 16:07:01 +00:00
|
|
|
|
example = "0.5 0 0 0 0.8 0.1 0 0 1";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
description =
|
2022-08-12 12:06:08 +00:00
|
|
|
|
lib.mdDoc ''
|
2021-12-06 16:07:01 +00:00
|
|
|
|
A string of 9 space-separated floating point numbers. Sets the calibration matrix to the
|
2020-04-24 23:36:52 +00:00
|
|
|
|
3x3 matrix where the first row is (abc), the second row is (def) and the third row is (ghi).
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
clickMethod = mkOption {
|
|
|
|
|
type = types.nullOr (types.enum [ "none" "buttonareas" "clickfinger" ]);
|
|
|
|
|
default = null;
|
2021-12-06 16:07:01 +00:00
|
|
|
|
example = "buttonareas";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
description =
|
2022-08-12 12:06:08 +00:00
|
|
|
|
lib.mdDoc ''
|
|
|
|
|
Enables a click method. Permitted values are `none`,
|
|
|
|
|
`buttonareas`, `clickfinger`.
|
2020-04-24 23:36:52 +00:00
|
|
|
|
Not all devices support all methods, if an option is unsupported,
|
|
|
|
|
the default click method for this device is used.
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
leftHanded = mkOption {
|
|
|
|
|
type = types.bool;
|
|
|
|
|
default = false;
|
2022-08-12 12:06:08 +00:00
|
|
|
|
description = lib.mdDoc "Enables left-handed button orientation, i.e. swapping left and right buttons.";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
middleEmulation = mkOption {
|
|
|
|
|
type = types.bool;
|
|
|
|
|
default = true;
|
|
|
|
|
description =
|
2022-08-12 12:06:08 +00:00
|
|
|
|
lib.mdDoc ''
|
2020-04-24 23:36:52 +00:00
|
|
|
|
Enables middle button emulation. When enabled, pressing the left and right buttons
|
|
|
|
|
simultaneously produces a middle mouse button click.
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
naturalScrolling = mkOption {
|
|
|
|
|
type = types.bool;
|
|
|
|
|
default = false;
|
2022-08-12 12:06:08 +00:00
|
|
|
|
description = lib.mdDoc "Enables or disables natural scrolling behavior.";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
scrollButton = mkOption {
|
|
|
|
|
type = types.nullOr types.int;
|
|
|
|
|
default = null;
|
|
|
|
|
example = 1;
|
|
|
|
|
description =
|
2022-08-12 12:06:08 +00:00
|
|
|
|
lib.mdDoc ''
|
2020-04-24 23:36:52 +00:00
|
|
|
|
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.
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
scrollMethod = mkOption {
|
|
|
|
|
type = types.enum [ "twofinger" "edge" "button" "none" ];
|
|
|
|
|
default = "twofinger";
|
|
|
|
|
example = "edge";
|
|
|
|
|
description =
|
2022-08-12 12:06:08 +00:00
|
|
|
|
lib.mdDoc ''
|
|
|
|
|
Specify the scrolling method: `twofinger`, `edge`,
|
|
|
|
|
`button`, or `none`
|
2020-04-24 23:36:52 +00:00
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
horizontalScrolling = mkOption {
|
|
|
|
|
type = types.bool;
|
|
|
|
|
default = true;
|
|
|
|
|
description =
|
2022-08-12 12:06:08 +00:00
|
|
|
|
lib.mdDoc ''
|
2020-04-24 23:36:52 +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.
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
sendEventsMode = mkOption {
|
|
|
|
|
type = types.enum [ "disabled" "enabled" "disabled-on-external-mouse" ];
|
|
|
|
|
default = "enabled";
|
|
|
|
|
example = "disabled";
|
|
|
|
|
description =
|
2022-08-12 12:06:08 +00:00
|
|
|
|
lib.mdDoc ''
|
|
|
|
|
Sets the send events mode to `disabled`, `enabled`,
|
|
|
|
|
or `disabled-on-external-mouse`
|
2020-04-24 23:36:52 +00:00
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
tapping = mkOption {
|
|
|
|
|
type = types.bool;
|
|
|
|
|
default = true;
|
|
|
|
|
description =
|
2022-08-12 12:06:08 +00:00
|
|
|
|
lib.mdDoc ''
|
2020-04-24 23:36:52 +00:00
|
|
|
|
Enables or disables tap-to-click behavior.
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
2022-10-06 18:32:54 +00:00
|
|
|
|
tappingButtonMap = mkOption {
|
|
|
|
|
type = types.nullOr (types.enum [ "lrm" "lmr" ]);
|
|
|
|
|
default = null;
|
|
|
|
|
description = lib.mdDoc ''
|
|
|
|
|
Set the button mapping for 1/2/3-finger taps to left/right/middle or left/middle/right, respectively.
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
|
tappingDragLock = mkOption {
|
|
|
|
|
type = types.bool;
|
|
|
|
|
default = true;
|
|
|
|
|
description =
|
2022-08-12 12:06:08 +00:00
|
|
|
|
lib.mdDoc ''
|
2020-04-24 23:36:52 +00:00
|
|
|
|
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
|
2022-12-28 21:21:41 +00:00
|
|
|
|
timeout, the dragging process continues.
|
2020-04-24 23:36:52 +00:00
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
2021-09-18 10:52:07 +00:00
|
|
|
|
transformationMatrix = mkOption {
|
|
|
|
|
type = types.nullOr types.str;
|
|
|
|
|
default = null;
|
2021-12-06 16:07:01 +00:00
|
|
|
|
example = "0.5 0 0 0 0.8 0.1 0 0 1";
|
2022-08-12 12:06:08 +00:00
|
|
|
|
description = lib.mdDoc ''
|
2021-12-06 16:07:01 +00:00
|
|
|
|
A string of 9 space-separated floating point numbers. Sets the transformation matrix to
|
2021-09-18 10:52:07 +00:00
|
|
|
|
the 3x3 matrix where the first row is (abc), the second row is (def) and the third row is (ghi).
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
|
disableWhileTyping = mkOption {
|
|
|
|
|
type = types.bool;
|
|
|
|
|
default = false;
|
|
|
|
|
description =
|
2022-08-12 12:06:08 +00:00
|
|
|
|
lib.mdDoc ''
|
2020-04-24 23:36:52 +00:00
|
|
|
|
Disable input method while typing.
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
additionalOptions = mkOption {
|
|
|
|
|
type = types.lines;
|
|
|
|
|
default = "";
|
|
|
|
|
example =
|
|
|
|
|
''
|
|
|
|
|
Option "DragLockButtons" "L1 B1 L2 B2"
|
|
|
|
|
'';
|
2022-08-12 12:06:08 +00:00
|
|
|
|
description = lib.mdDoc ''
|
2021-02-05 17:12:51 +00:00
|
|
|
|
Additional options for libinput ${deviceType} driver. See
|
2022-08-12 12:06:08 +00:00
|
|
|
|
{manpage}`libinput(4)`
|
2020-04-24 23:36:52 +00:00
|
|
|
|
for available options.";
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
2021-02-05 17:12:51 +00:00
|
|
|
|
mkX11ConfigForDevice = deviceType: matchIs: ''
|
2021-06-28 23:13:55 +00:00
|
|
|
|
Identifier "libinput ${deviceType} configuration"
|
|
|
|
|
MatchDriver "libinput"
|
|
|
|
|
MatchIs${matchIs} "${xorgBool true}"
|
|
|
|
|
${optionalString (cfg.${deviceType}.dev != null) ''MatchDevicePath "${cfg.${deviceType}.dev}"''}
|
|
|
|
|
Option "AccelProfile" "${cfg.${deviceType}.accelProfile}"
|
|
|
|
|
${optionalString (cfg.${deviceType}.accelSpeed != null) ''Option "AccelSpeed" "${cfg.${deviceType}.accelSpeed}"''}
|
|
|
|
|
${optionalString (cfg.${deviceType}.buttonMapping != null) ''Option "ButtonMapping" "${cfg.${deviceType}.buttonMapping}"''}
|
|
|
|
|
${optionalString (cfg.${deviceType}.calibrationMatrix != null) ''Option "CalibrationMatrix" "${cfg.${deviceType}.calibrationMatrix}"''}
|
2021-09-18 10:52:07 +00:00
|
|
|
|
${optionalString (cfg.${deviceType}.transformationMatrix != null) ''Option "TransformationMatrix" "${cfg.${deviceType}.transformationMatrix}"''}
|
2021-06-28 23:13:55 +00:00
|
|
|
|
${optionalString (cfg.${deviceType}.clickMethod != null) ''Option "ClickMethod" "${cfg.${deviceType}.clickMethod}"''}
|
|
|
|
|
Option "LeftHanded" "${xorgBool cfg.${deviceType}.leftHanded}"
|
|
|
|
|
Option "MiddleEmulation" "${xorgBool cfg.${deviceType}.middleEmulation}"
|
|
|
|
|
Option "NaturalScrolling" "${xorgBool cfg.${deviceType}.naturalScrolling}"
|
|
|
|
|
${optionalString (cfg.${deviceType}.scrollButton != null) ''Option "ScrollButton" "${toString cfg.${deviceType}.scrollButton}"''}
|
|
|
|
|
Option "ScrollMethod" "${cfg.${deviceType}.scrollMethod}"
|
|
|
|
|
Option "HorizontalScrolling" "${xorgBool cfg.${deviceType}.horizontalScrolling}"
|
|
|
|
|
Option "SendEventsMode" "${cfg.${deviceType}.sendEventsMode}"
|
|
|
|
|
Option "Tapping" "${xorgBool cfg.${deviceType}.tapping}"
|
2022-10-06 18:32:54 +00:00
|
|
|
|
${optionalString (cfg.${deviceType}.tappingButtonMap != null) ''Option "TappingButtonMap" "${cfg.${deviceType}.tappingButtonMap}"''}
|
2021-06-28 23:13:55 +00:00
|
|
|
|
Option "TappingDragLock" "${xorgBool cfg.${deviceType}.tappingDragLock}"
|
|
|
|
|
Option "DisableWhileTyping" "${xorgBool cfg.${deviceType}.disableWhileTyping}"
|
|
|
|
|
${cfg.${deviceType}.additionalOptions}
|
|
|
|
|
'';
|
2021-02-05 17:12:51 +00:00
|
|
|
|
in {
|
|
|
|
|
|
|
|
|
|
imports =
|
|
|
|
|
(map (option: mkRenamedOptionModule ([ "services" "xserver" "libinput" option ]) [ "services" "xserver" "libinput" "touchpad" option ]) [
|
|
|
|
|
"accelProfile"
|
|
|
|
|
"accelSpeed"
|
|
|
|
|
"buttonMapping"
|
|
|
|
|
"calibrationMatrix"
|
|
|
|
|
"clickMethod"
|
|
|
|
|
"leftHanded"
|
|
|
|
|
"middleEmulation"
|
|
|
|
|
"naturalScrolling"
|
|
|
|
|
"scrollButton"
|
|
|
|
|
"scrollMethod"
|
|
|
|
|
"horizontalScrolling"
|
|
|
|
|
"sendEventsMode"
|
|
|
|
|
"tapping"
|
2022-10-06 18:32:54 +00:00
|
|
|
|
"tappingButtonMap"
|
2021-02-05 17:12:51 +00:00
|
|
|
|
"tappingDragLock"
|
2021-09-18 10:52:07 +00:00
|
|
|
|
"transformationMatrix"
|
2021-02-05 17:12:51 +00:00
|
|
|
|
"disableWhileTyping"
|
|
|
|
|
"additionalOptions"
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
options = {
|
|
|
|
|
|
|
|
|
|
services.xserver.libinput = {
|
2023-05-24 13:37:59 +00:00
|
|
|
|
enable = mkEnableOption (lib.mdDoc "libinput") // {
|
|
|
|
|
default = config.services.xserver.enable;
|
|
|
|
|
defaultText = lib.literalExpression "config.services.xserver.enable";
|
|
|
|
|
};
|
2021-02-05 17:12:51 +00:00
|
|
|
|
mouse = mkConfigForDevice "mouse";
|
|
|
|
|
touchpad = mkConfigForDevice "touchpad";
|
|
|
|
|
};
|
2020-04-24 23:36:52 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
|
|
|
|
|
|
services.xserver.modules = [ pkgs.xorg.xf86inputlibinput ];
|
|
|
|
|
|
|
|
|
|
environment.systemPackages = [ pkgs.xorg.xf86inputlibinput ];
|
|
|
|
|
|
|
|
|
|
environment.etc =
|
|
|
|
|
let cfgPath = "X11/xorg.conf.d/40-libinput.conf";
|
|
|
|
|
in {
|
|
|
|
|
${cfgPath} = {
|
|
|
|
|
source = pkgs.xorg.xf86inputlibinput.out + "/share/" + cfgPath;
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
services.udev.packages = [ pkgs.libinput.out ];
|
|
|
|
|
|
2021-02-05 17:12:51 +00:00
|
|
|
|
services.xserver.inputClassSections = [
|
|
|
|
|
(mkX11ConfigForDevice "mouse" "Pointer")
|
|
|
|
|
(mkX11ConfigForDevice "touchpad" "Touchpad")
|
|
|
|
|
];
|
2020-04-24 23:36:52 +00: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).";
|
|
|
|
|
} */
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|