Compare commits
No commits in common. "d854f9bd809bfb5d322db6d81bb1d6b4baf2a45a" and "ef1f0b0513ed7cc2fa56636c59cb512f2eb6807e" have entirely different histories.
d854f9bd80
...
ef1f0b0513
5 changed files with 7 additions and 23 deletions
|
@ -37,7 +37,7 @@
|
||||||
#?? sudo btrfs inspect-internal map-swapfile -r /swap/swapfile
|
#?? sudo btrfs inspect-internal map-swapfile -r /swap/swapfile
|
||||||
"resume_offset=533760"
|
"resume_offset=533760"
|
||||||
|
|
||||||
# Fix battery drain with suspend
|
# Fix battery drain with suspend-then-hibernate
|
||||||
# https://wiki.archlinux.org/title/Framework_Laptop_13#Suspend-then-hibernate_on_AMD_version
|
# https://wiki.archlinux.org/title/Framework_Laptop_13#Suspend-then-hibernate_on_AMD_version
|
||||||
"rtc_cmos.use_acpi_alarm=1"
|
"rtc_cmos.use_acpi_alarm=1"
|
||||||
|
|
||||||
|
|
|
@ -46,7 +46,7 @@ in {
|
||||||
|
|
||||||
{
|
{
|
||||||
timeout = 60 * 60; # Seconds
|
timeout = 60 * 60; # Seconds
|
||||||
on-timeout = "${pw-cli} info all | ${grep} running || ${systemctl} hybrid-sleep"; # Suspend if no audio
|
on-timeout = "${pw-cli} info all | ${grep} running || ${systemctl} suspend-then-hibernate"; # Suspend if no audio
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
|
@ -10,7 +10,7 @@ in {
|
||||||
|
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
services.logind = {
|
services.logind = {
|
||||||
lidSwitch = "hybrid-sleep"; # Laptop lid switch
|
lidSwitch = "suspend-then-hibernate"; # Laptop lid switch
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
with lib; let
|
with lib; let
|
||||||
grep = "${pkgs.gnugrep}/bin/grep";
|
|
||||||
powerprofilesctl = "${pkgs.power-profiles-daemon}/bin/powerprofilesctl";
|
powerprofilesctl = "${pkgs.power-profiles-daemon}/bin/powerprofilesctl";
|
||||||
|
|
||||||
cfg = config.custom.services.power-profiles-daemon;
|
cfg = config.custom.services.power-profiles-daemon;
|
||||||
|
@ -29,27 +28,12 @@ in {
|
||||||
# Switch to power-saver mode when on battery
|
# Switch to power-saver mode when on battery
|
||||||
# https://wiki.archlinux.org/title/Power_management#Using_a_script_and_an_udev_rule
|
# https://wiki.archlinux.org/title/Power_management#Using_a_script_and_an_udev_rule
|
||||||
udev.extraRules = mkIf cfg.auto ''
|
udev.extraRules = mkIf cfg.auto ''
|
||||||
# AC
|
|
||||||
SUBSYSTEM=="power_supply", ATTR{online}=="1", RUN+="${powerprofilesctl} set balanced"
|
|
||||||
# Battery
|
# Battery
|
||||||
SUBSYSTEM=="power_supply", ATTR{online}=="0", RUN+="${powerprofilesctl} set power-saver"
|
SUBSYSTEM=="power_supply", ATTR{online}=="0", RUN+="${powerprofilesctl} set power-saver"
|
||||||
'';
|
|
||||||
};
|
|
||||||
|
|
||||||
# Set power profile at boot/resume
|
# AC
|
||||||
powerManagement = let
|
SUBSYSTEM=="power_supply", ATTR{online}=="1", RUN+="${powerprofilesctl} set balanced"
|
||||||
set_profile = toString (pkgs.writeShellScript "set_profile" ''
|
'';
|
||||||
if ${grep} 1 /sys/class/power_supply/*/online; then
|
|
||||||
# AC
|
|
||||||
${powerprofilesctl} set balanced
|
|
||||||
else
|
|
||||||
# Battery
|
|
||||||
${powerprofilesctl} set power-saver
|
|
||||||
fi
|
|
||||||
'');
|
|
||||||
in {
|
|
||||||
powerUpCommands = set_profile;
|
|
||||||
resumeCommands = set_profile;
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,7 +61,7 @@ in {
|
||||||
# https://github.com/NixOS/nixpkgs/pull/259196
|
# https://github.com/NixOS/nixpkgs/pull/259196
|
||||||
# Suspend system
|
# Suspend system
|
||||||
{
|
{
|
||||||
command = "${systemctl} hybrid-sleep";
|
command = "${systemctl} suspend-then-hibernate";
|
||||||
timeout = 60 * 60; # Minutes * 60
|
timeout = 60 * 60; # Minutes * 60
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
Loading…
Add table
Reference in a new issue