1
1
Fork 0

niri: fix trackball device detection

Signed-off-by: Myned <dev@bjork.tech>
This commit is contained in:
Myned 2025-03-06 11:13:25 -06:00
parent 50cf7f508e
commit 88c0fcb0d4
Signed by: Myned
GPG key ID: C7224454F7881A34
2 changed files with 42 additions and 13 deletions
options/custom
desktops/niri
services

View file

@ -33,11 +33,11 @@ in {
repeat-rate = 40; repeat-rate = 40;
}; };
# BUG: Applies to trackball device, switch to "flat" when per-device configuration is supported # TODO: Update when per-device configuration is supported
# https://github.com/YaLTeR/niri/issues/371 # https://github.com/YaLTeR/niri/issues/371
# https://github.com/sodiboo/niri-flake/blob/main/docs.md#programsnirisettingsinputmouseaccel-profile # https://github.com/sodiboo/niri-flake/blob/main/docs.md#programsnirisettingsinputmouseaccel-profile
mouse = { mouse = {
accel-profile = "adaptive"; accel-profile = "adaptive"; # flat
accel-speed = -0.7; accel-speed = -0.7;
scroll-factor = 1.25; scroll-factor = 1.25;
}; };
@ -55,8 +55,10 @@ in {
# https://github.com/sodiboo/niri-flake/blob/main/docs.md#programsnirisettingsinputtrackballaccel-profile # https://github.com/sodiboo/niri-flake/blob/main/docs.md#programsnirisettingsinputtrackballaccel-profile
trackball = { trackball = {
accel-profile = "adaptive"; accel-profile = "adaptive";
accel-speed = -0.5; accel-speed = -0.8;
left-handed = true;
middle-emulation = true; middle-emulation = true;
natural-scroll = true;
}; };
}; };
} }

View file

@ -6,19 +6,46 @@
}: }:
with lib; let with lib; let
cfg = config.custom.services.udev; cfg = config.custom.services.udev;
chgrp = getExe' pkgs.coreutils "chgrp";
chmod = getExe' pkgs.coreutils "chmod";
in { in {
options.custom.services.udev.enable = mkOption {default = false;}; options.custom.services.udev = {
enable = mkOption {default = false;};
backlight = mkOption {default = true;};
input = mkOption {default = true;};
};
config = mkIf cfg.enable { config = mkIf cfg.enable {
# https://wiki.archlinux.org/title/Udev # https://wiki.archlinux.org/title/Udev
services.udev.extraRules =
optionalString cfg.backlight ''
# Allow video group to change display brightness # Allow video group to change display brightness
# https://raw.githubusercontent.com/ErikReider/SwayOSD/main/data/udev/99-swayosd.rules # https://raw.githubusercontent.com/ErikReider/SwayOSD/main/data/udev/99-swayosd.rules
services.udev.extraRules = let ACTION=="add", \
chgrp = "${pkgs.coreutils}/bin/chgrp"; SUBSYSTEM=="backlight", \
chmod = "${pkgs.coreutils}/bin/chmod"; RUN+="${chgrp} video /sys/class/backlight/%k/brightness"
in '' ACTION=="add", \
ACTION=="add", SUBSYSTEM=="backlight", RUN+="${chgrp} video /sys/class/backlight/%k/brightness" SUBSYSTEM=="backlight", \
ACTION=="add", SUBSYSTEM=="backlight", RUN+="${chmod} g+w /sys/class/backlight/%k/brightness" RUN+="${chmod} g+w /sys/class/backlight/%k/brightness"
''
+ optionalString cfg.input ''
# Per-device input configuration
# https://wiki.archlinux.org/title/Libinput#Via_Udev_Rule
# https://wayland.freedesktop.org/libinput/doc/latest/device-configuration-via-udev.html
#?? sudo libinput list-devices
#?? sudo udevadm info /dev/input/event*
#?? sudo udevadm trigger /dev/input/event*
# Kensington Orbit
ENV{ID_USB_SERIAL}=="Kensington_ORBIT_WIRELESS_TB", \
ENV{ID_INPUT_MOUSE}="", \
ENV{ID_INPUT_TRACKBALL}="1"
# ProtoArc EM04
ENV{ID_USB_SERIAL}=="Nordic_2.4G_Wireless_Receiver", \
ENV{ID_INPUT_MOUSE}="", \
ENV{ID_INPUT_TRACKBALL}="1"
''; '';
}; };
} }