2025-06-01 15:54:24 -04:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
services.udev = {
|
|
|
|
extraRules = ''
|
|
|
|
KERNEL=="uinput", MODE="0660", GROUP="uinput", OPTIONS+="static_node=uinput"
|
|
|
|
DEVPATH=="/devices/virtual/misc/cpu_dma_latency", OWNER="root", GROUP="audio", MODE="0660"
|
|
|
|
ACTION=="add", SUBSYSTEM=="backlight", KERNEL=="ddcci*", RUN+="${pkgs.coreutils-full}/bin/chgrp video /sys/class/backlight/%k/brightness"
|
|
|
|
ACTION=="add", SUBSYSTEM=="backlight", KERNEL=="ddcci*", RUN+="${pkgs.coreutils-full}/bin/chmod a+w /sys/class/backlight/%k/brightness"
|
|
|
|
ACTION=="add", SUBSYSTEM=="i2c-dev", ATTR{name}=="AMDGPU DM*", TAG+="ddcci", TAG+="systemd", ENV{SYSTEMD_WANTS}+="ddcci@$kernel.service"
|
|
|
|
ACTION=="add", SUBSYSTEM=="i2c-dev", ATTR{name}=="NVIDIA i2c adapter*", TAG+="ddcci", TAG+="systemd", ENV{SYSTEMD_WANTS}+="ddcci@$kernel.service"
|
|
|
|
SUBSYSTEM=="i2c", ACTION=="add", ATTR{name}=="AMDGPU DM aux hw bus 3", RUN+="${pkgs.bash}/bin/bash -c 'sleep 30; printf ddcci\ 0x37 > /sys/bus/i2c/devices/i2c-17/new_device'"
|
|
|
|
'';
|
|
|
|
packages = [
|
|
|
|
pkgs.via
|
|
|
|
pkgs.vial
|
|
|
|
pkgs.ddcutil
|
|
|
|
pkgs.game-devices-udev-rules
|
2025-06-20 18:42:46 -04:00
|
|
|
# pkgs.sane-airscan
|
2025-06-01 15:54:24 -04:00
|
|
|
pkgs.utsushi
|
|
|
|
pkgs.openrgb-with-all-plugins
|
|
|
|
|
|
|
|
pkgs.gnome-settings-daemon
|
|
|
|
pkgs.gnome-keyring
|
|
|
|
|
|
|
|
(pkgs.writeTextFile {
|
|
|
|
name = "on-battery";
|
|
|
|
text = ''
|
|
|
|
# Rule for when switching to battery
|
|
|
|
SUBSYSTEM=="power_supply", ENV{POWER_SUPPLY_ONLINE}=="0", RUN+="${pkgs.power-profiles-daemon}/bin/powerprofilesctl set balanced"
|
|
|
|
'';
|
|
|
|
destination = "/etc/udev/rules.d/60-onbattery.rules";
|
|
|
|
})
|
|
|
|
(pkgs.writeTextFile {
|
|
|
|
name = "on-power";
|
|
|
|
text = ''
|
|
|
|
# Rule for when switching to ac
|
|
|
|
SUBSYSTEM=="power_supply", ENV{POWER_SUPPLY_ONLINE}=="1", RUN+="${pkgs.power-profiles-daemon}/bin/powerprofilesctl set performance"
|
|
|
|
'';
|
|
|
|
destination = "/etc/udev/rules.d/61-onpower.rules";
|
|
|
|
})
|
|
|
|
(pkgs.writeTextFile {
|
|
|
|
name = "hibernate-low-battery";
|
|
|
|
text = ''
|
|
|
|
# Suspend the system when battery level drops to 5% or lower
|
|
|
|
SUBSYSTEM=="power_supply", ATTR{status}=="Discharging", ATTR{capacity}=="[0-5]", RUN+="${pkgs.systemd}/bin/systemctl hibernate"
|
|
|
|
'';
|
|
|
|
destination = "/etc/udev/rules.d/99-hibernate-low-battery.rules";
|
|
|
|
})
|
|
|
|
(pkgs.writeTextFile {
|
|
|
|
name = "on-battery-power-saver";
|
|
|
|
text = ''
|
|
|
|
# Switch to power-saver when battery below 50%
|
|
|
|
SUBSYSTEM=="power_supply", ATTR{status}=="Discharging", ATTR{capacity}=="[0-5][0-9]", RUN+="${pkgs.power-profiles-daemon}/bin/powerprofilesctl set power-saver"
|
|
|
|
'';
|
|
|
|
destination = "/etc/udev/rules.d/62-power-save-battery.rules";
|
|
|
|
})
|
|
|
|
];
|
|
|
|
};
|
|
|
|
}
|