37 lines
876 B
Nix
Raw Normal View History

2024-04-20 09:42:06 -04:00
{
config,
pkgs,
lib,
...
}:
{
config = lib.mkIf (config.physical && !config.server) {
2022-12-21 14:18:03 -07:00
# Use power button to sleep instead of poweroff
services.logind.powerKey = "suspend";
services.logind.powerKeyLongPress = "poweroff";
2022-12-21 14:18:03 -07:00
# Prevent wake from keyboard
powerManagement.powerDownCommands = ''
2023-04-01 20:21:26 -04:00
set +e
2023-02-22 23:46:24 -05:00
2023-04-01 20:21:26 -04:00
# Fix for Gigabyte motherboard
# /r/archlinux/comments/y7b97e/my_computer_wakes_up_immediately_after_i_suspend/isu99sr/
2023-06-01 22:54:08 -04:00
# Disable if enabled
if (grep "GPP0.*enabled" /proc/acpi/wakeup >/dev/null); then
echo GPP0 | ${pkgs.doas}/bin/doas tee /proc/acpi/wakeup
fi
2022-12-21 14:18:03 -07:00
2023-04-15 10:11:30 -04:00
sleep 2
2023-04-01 20:21:26 -04:00
set -e
'';
2023-02-22 23:46:24 -05:00
2023-04-02 08:22:28 -04:00
services.udev.extraRules = ''
ACTION=="add", SUBSYSTEM=="usb", DRIVER=="usb", ATTR{power/wakeup}="disabled"
ACTION=="add", SUBSYSTEM=="i2c", ATTR{power/wakeup}="disabled"
'';
2022-12-21 14:18:03 -07:00
};
}