From 2ef1d58ea7b136a05c8b8f12685f5d9f90ba9465 Mon Sep 17 00:00:00 2001 From: kenji Date: Sun, 11 Jan 2026 19:02:18 -0600 Subject: [PATCH] fix(power): writes `disabled` on certain usb devices to avoid random wake-ups --- modules/nixos/power.nix | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/modules/nixos/power.nix b/modules/nixos/power.nix index feafb5a..85e1faa 100644 --- a/modules/nixos/power.nix +++ b/modules/nixos/power.nix @@ -1,4 +1,21 @@ {pkgs, ...}: { - # USB wakeup configuration - Temporarily Disabled - # systemd.services.disable-usb-wakeups = { ... }; + # 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; + }; + }; } \ No newline at end of file