diff --git a/config.nix b/config.nix index e668e9c..ade78a3 100644 --- a/config.nix +++ b/config.nix @@ -40,6 +40,13 @@ wallpaper = "firewatch.png"; kb_options = ""; }; + wakeup = { + mouse = { + disable = true; + vendor = "3710"; + product = "5406"; + }; + }; firefox = { bookmarks = [ { diff --git a/modules/nixos/default.nix b/modules/nixos/default.nix index 42db347..d114eb6 100644 --- a/modules/nixos/default.nix +++ b/modules/nixos/default.nix @@ -11,6 +11,7 @@ ./kernel.nix ./nix.nix ./power.nix # TODO: this one has to be optional + ./mouse-wakeup.nix ./programs.nix ./security.nix ./services.nix diff --git a/modules/nixos/mouse-wakeup.nix b/modules/nixos/mouse-wakeup.nix new file mode 100644 index 0000000..306bdcb --- /dev/null +++ b/modules/nixos/mouse-wakeup.nix @@ -0,0 +1,14 @@ +{ lib, myConfig, ... }: + +with lib; +let + cfg = myConfig.wakeup.mouse or {}; +in +{ + config = mkIf (cfg.disable or false && cfg.vendor != null && cfg.product != null) { + services.udev.extraRules = '' + # Disable wakeup for mouse configured in config.nix + ACTION=="add", SUBSYSTEM=="usb", ATTRS{idVendor}=="${cfg.vendor}", ATTRS{idProduct}=="${cfg.product}", ATTR{power/wakeup}="disabled" + ''; + }; +} diff --git a/modules/nixos/power.nix b/modules/nixos/power.nix index 85e1faa..93f0261 100644 --- a/modules/nixos/power.nix +++ b/modules/nixos/power.nix @@ -1,21 +1,4 @@ -{pkgs, ...}: { - # USB wakeup configuration - # Disabling USB wakeups to prevent accidental wakeups from mouse/keyboard/bluetooth - systemd.services.disable-usb-wakeups = { - description = "Disable USB wakeup triggers"; - wantedBy = ["multi-user.target" "post-resume.target"]; - after = ["post-resume.target"]; - serviceConfig = { - Type = "oneshot"; - ExecStart = pkgs.writeShellScript "disable-usb-wakeups" '' - for device in XHC0 XHC1 XHC2 XH00 GPP0 GPP7; do - if grep -q "$device.*enabled" /proc/acpi/wakeup; then - echo "Disabling wakeup for $device" - echo "$device" > /proc/acpi/wakeup - fi - done - ''; - RemainAfterExit = true; - }; - }; +{ + # This file is intentionally left blank. + # USB wakeup is now handled by modules/nixos/mouse-wakeup.nix } \ No newline at end of file