2018-07-20 20:56:59 +00:00
|
|
|
{ config, lib, ... }:
|
2014-05-23 08:18:03 +00:00
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
{
|
|
|
|
###### interface
|
|
|
|
|
|
|
|
options = {
|
|
|
|
|
|
|
|
hardware.trackpoint = {
|
|
|
|
|
|
|
|
enable = mkOption {
|
|
|
|
default = false;
|
|
|
|
type = types.bool;
|
|
|
|
description = lib.mdDoc ''
|
|
|
|
Enable sensitivity and speed configuration for trackpoints.
|
|
|
|
'';
|
|
|
|
};
|
2015-03-14 23:04:55 +00:00
|
|
|
|
2014-05-23 08:18:03 +00:00
|
|
|
sensitivity = mkOption {
|
|
|
|
default = 128;
|
|
|
|
example = 255;
|
|
|
|
type = types.int;
|
|
|
|
description = lib.mdDoc ''
|
|
|
|
Configure the trackpoint sensitivity. By default, the kernel
|
|
|
|
configures 128.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
speed = mkOption {
|
|
|
|
default = 97;
|
|
|
|
example = 255;
|
|
|
|
type = types.int;
|
|
|
|
description = lib.mdDoc ''
|
2016-01-10 23:26:27 +00:00
|
|
|
Configure the trackpoint speed. By default, the kernel
|
2014-05-23 08:18:03 +00:00
|
|
|
configures 97.
|
|
|
|
'';
|
|
|
|
};
|
2014-08-13 10:10:52 +00:00
|
|
|
|
|
|
|
emulateWheel = mkOption {
|
|
|
|
default = false;
|
|
|
|
type = types.bool;
|
|
|
|
description = lib.mdDoc ''
|
|
|
|
Enable scrolling while holding the middle mouse button.
|
|
|
|
'';
|
|
|
|
};
|
2015-03-14 23:04:55 +00:00
|
|
|
|
2015-05-25 17:55:26 +00:00
|
|
|
fakeButtons = mkOption {
|
|
|
|
default = false;
|
|
|
|
type = types.bool;
|
|
|
|
description = lib.mdDoc ''
|
|
|
|
Switch to "bare" PS/2 mouse support in case Trackpoint buttons are not recognized
|
|
|
|
properly. This can happen for example on models like the L430, T450, T450s, on
|
|
|
|
which the Trackpoint buttons are actually a part of the Synaptics touchpad.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2018-07-24 16:11:56 +00:00
|
|
|
device = mkOption {
|
|
|
|
default = "TPPS/2 IBM TrackPoint";
|
|
|
|
type = types.str;
|
|
|
|
description = lib.mdDoc ''
|
|
|
|
The device name of the trackpoint. You can check with xinput.
|
|
|
|
Some newer devices (example x1c6) use "TPPS/2 Elan TrackPoint".
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2014-05-23 08:18:03 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
###### implementation
|
|
|
|
|
2015-05-25 17:55:26 +00:00
|
|
|
config =
|
|
|
|
let cfg = config.hardware.trackpoint; in
|
|
|
|
mkMerge [
|
|
|
|
(mkIf cfg.enable {
|
2014-08-13 10:10:52 +00:00
|
|
|
services.udev.extraRules =
|
2014-07-28 21:33:05 +00:00
|
|
|
''
|
2018-07-24 16:11:56 +00:00
|
|
|
ACTION=="add|change", SUBSYSTEM=="input", ATTR{name}=="${cfg.device}", ATTR{device/speed}="${toString cfg.speed}", ATTR{device/sensitivity}="${toString cfg.sensitivity}"
|
2014-07-28 21:33:05 +00:00
|
|
|
'';
|
2014-05-23 08:18:03 +00:00
|
|
|
|
2023-10-28 22:05:14 +00:00
|
|
|
systemd.services.trackpoint = {
|
|
|
|
wantedBy = [ "sysinit.target" ] ;
|
|
|
|
before = [ "sysinit.target" "shutdown.target" ];
|
|
|
|
conflicts = [ "shutdown.target" ];
|
|
|
|
unitConfig.DefaultDependencies = false;
|
|
|
|
serviceConfig.Type = "oneshot";
|
|
|
|
serviceConfig.RemainAfterExit = true;
|
|
|
|
serviceConfig.ExecStart = ''
|
|
|
|
${config.systemd.package}/bin/udevadm trigger --attr-match=name="${cfg.device}
|
2014-08-13 10:10:52 +00:00
|
|
|
'';
|
2023-10-28 22:05:14 +00:00
|
|
|
};
|
2014-08-13 10:10:52 +00:00
|
|
|
})
|
|
|
|
|
2015-05-25 17:55:26 +00:00
|
|
|
(mkIf (cfg.emulateWheel) {
|
2021-06-17 01:15:13 +00:00
|
|
|
services.xserver.inputClassSections = [
|
|
|
|
''
|
|
|
|
Identifier "Trackpoint Wheel Emulation"
|
2018-07-24 16:11:56 +00:00
|
|
|
MatchProduct "${if cfg.fakeButtons then "PS/2 Generic Mouse" else "ETPS/2 Elantech TrackPoint|Elantech PS/2 TrackPoint|TPPS/2 IBM TrackPoint|DualPoint Stick|Synaptics Inc. Composite TouchPad / TrackPoint|ThinkPad USB Keyboard with TrackPoint|USB Trackpoint pointing device|Composite TouchPad / TrackPoint|${cfg.device}"}"
|
2015-05-25 17:55:26 +00:00
|
|
|
MatchDevicePath "/dev/input/event*"
|
|
|
|
Option "EmulateWheel" "true"
|
|
|
|
Option "EmulateWheelButton" "2"
|
|
|
|
Option "Emulate3Buttons" "false"
|
|
|
|
Option "XAxisMapping" "6 7"
|
|
|
|
Option "YAxisMapping" "4 5"
|
2021-06-17 01:15:13 +00:00
|
|
|
''
|
|
|
|
];
|
2015-05-25 17:55:26 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
(mkIf cfg.fakeButtons {
|
|
|
|
boot.extraModprobeConfig = "options psmouse proto=bare";
|
2014-08-13 10:10:52 +00:00
|
|
|
})
|
|
|
|
];
|
2014-05-23 08:18:03 +00:00
|
|
|
}
|