Compare commits
2 commits
ef1f0b0513
...
d854f9bd80
Author | SHA1 | Date | |
---|---|---|---|
d854f9bd80 | |||
c656090494 |
5 changed files with 23 additions and 7 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-then-hibernate
|
# Fix battery drain with suspend
|
||||||
# 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} suspend-then-hibernate"; # Suspend if no audio
|
on-timeout = "${pw-cli} info all | ${grep} running || ${systemctl} hybrid-sleep"; # Suspend if no audio
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
|
@ -10,7 +10,7 @@ in {
|
||||||
|
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
services.logind = {
|
services.logind = {
|
||||||
lidSwitch = "suspend-then-hibernate"; # Laptop lid switch
|
lidSwitch = "hybrid-sleep"; # Laptop lid switch
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
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;
|
||||||
|
@ -28,12 +29,27 @@ 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 ''
|
||||||
# Battery
|
|
||||||
SUBSYSTEM=="power_supply", ATTR{online}=="0", RUN+="${powerprofilesctl} set power-saver"
|
|
||||||
|
|
||||||
# AC
|
# AC
|
||||||
SUBSYSTEM=="power_supply", ATTR{online}=="1", RUN+="${powerprofilesctl} set balanced"
|
SUBSYSTEM=="power_supply", ATTR{online}=="1", RUN+="${powerprofilesctl} set balanced"
|
||||||
|
# Battery
|
||||||
|
SUBSYSTEM=="power_supply", ATTR{online}=="0", RUN+="${powerprofilesctl} set power-saver"
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
# Set power profile at boot/resume
|
||||||
|
powerManagement = let
|
||||||
|
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} suspend-then-hibernate";
|
command = "${systemctl} hybrid-sleep";
|
||||||
timeout = 60 * 60; # Minutes * 60
|
timeout = 60 * 60; # Minutes * 60
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
Loading…
Add table
Reference in a new issue