Skip to content

Commit

Permalink
nixos/modules/tasks/trackpoint.nix: remove with lib;
Browse files Browse the repository at this point in the history
  • Loading branch information
Stunkymonkey committed Sep 11, 2024
1 parent 7c55569 commit c2f60b2
Showing 1 changed file with 16 additions and 19 deletions.
35 changes: 16 additions & 19 deletions nixos/modules/tasks/trackpoint.nix
Original file line number Diff line number Diff line change
@@ -1,63 +1,60 @@
{ config, lib, ... }:

with lib;

{
###### interface

options = {

hardware.trackpoint = {

enable = mkOption {
enable = lib.mkOption {
default = false;
type = types.bool;
type = lib.types.bool;
description = ''
Enable sensitivity and speed configuration for trackpoints.
'';
};

sensitivity = mkOption {
sensitivity = lib.mkOption {
default = 128;
example = 255;
type = types.int;
type = lib.types.int;
description = ''
Configure the trackpoint sensitivity. By default, the kernel
configures 128.
'';
};

speed = mkOption {
speed = lib.mkOption {
default = 97;
example = 255;
type = types.int;
type = lib.types.int;
description = ''
Configure the trackpoint speed. By default, the kernel
configures 97.
'';
};

emulateWheel = mkOption {
emulateWheel = lib.mkOption {
default = false;
type = types.bool;
type = lib.types.bool;
description = ''
Enable scrolling while holding the middle mouse button.
'';
};

fakeButtons = mkOption {
fakeButtons = lib.mkOption {
default = false;
type = types.bool;
type = lib.types.bool;
description = ''
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.
'';
};

device = mkOption {
device = lib.mkOption {
default = "TPPS/2 IBM TrackPoint";
type = types.str;
type = lib.types.str;
description = ''
The device name of the trackpoint. You can check with xinput.
Some newer devices (example x1c6) use "TPPS/2 Elan TrackPoint".
Expand All @@ -73,8 +70,8 @@ with lib;

config =
let cfg = config.hardware.trackpoint; in
mkMerge [
(mkIf cfg.enable {
lib.mkMerge [
(lib.mkIf cfg.enable {
services.udev.extraRules =
''
ACTION=="add|change", SUBSYSTEM=="input", ATTR{name}=="${cfg.device}", ATTR{device/speed}="${toString cfg.speed}", ATTR{device/sensitivity}="${toString cfg.sensitivity}"
Expand All @@ -93,7 +90,7 @@ with lib;
};
})

(mkIf (cfg.emulateWheel) {
(lib.mkIf (cfg.emulateWheel) {
services.xserver.inputClassSections = [
''
Identifier "Trackpoint Wheel Emulation"
Expand All @@ -108,7 +105,7 @@ with lib;
];
})

(mkIf cfg.fakeButtons {
(lib.mkIf cfg.fakeButtons {
boot.extraModprobeConfig = "options psmouse proto=bare";
})
];
Expand Down

0 comments on commit c2f60b2

Please sign in to comment.