32 current 1970-01-01 01:00:00 23.11.20240229.068d4db 6.1.79 *
This commit is contained in:
parent
72bfd4eb18
commit
2efaff82ae
@ -10,6 +10,7 @@
|
|||||||
imports = [
|
imports = [
|
||||||
# Include the results of the hardware scan.
|
# Include the results of the hardware scan.
|
||||||
./hardware-configuration.nix
|
./hardware-configuration.nix
|
||||||
|
./suspend-and-hibernate.nix
|
||||||
inputs.home-manager.nixosModules.default
|
inputs.home-manager.nixosModules.default
|
||||||
];
|
];
|
||||||
|
|
||||||
@ -122,6 +123,7 @@
|
|||||||
clang-tools
|
clang-tools
|
||||||
alejandra
|
alejandra
|
||||||
libnotify
|
libnotify
|
||||||
|
gnomeExtensions.hibernate-status-button
|
||||||
];
|
];
|
||||||
|
|
||||||
# Some programs need SUID wrappers, can be configured further or are
|
# Some programs need SUID wrappers, can be configured further or are
|
||||||
|
41
suspend-and-hibernate.nix
Normal file
41
suspend-and-hibernate.nix
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
{
|
||||||
|
config,
|
||||||
|
pkgs,
|
||||||
|
...
|
||||||
|
}: let
|
||||||
|
hibernateEnvironment = {
|
||||||
|
HIBERNATE_SECONDS = "3600";
|
||||||
|
HIBERNATE_LOCK = "/var/run/autohibernate.lock";
|
||||||
|
};
|
||||||
|
in {
|
||||||
|
systemd.services."awake-after-suspend-for-a-time" = {
|
||||||
|
description = "Sets up the suspend so that it'll wake for hibernation";
|
||||||
|
wantedBy = ["suspend.target"];
|
||||||
|
before = ["systemd-suspend.service"];
|
||||||
|
environment = hibernateEnvironment;
|
||||||
|
script = ''
|
||||||
|
curtime=$(date +%s)
|
||||||
|
echo "$curtime $1" >> /tmp/autohibernate.log
|
||||||
|
echo "$curtime" > $HIBERNATE_LOCK
|
||||||
|
${pkgs.utillinux}/bin/rtcwake -m no -s $HIBERNATE_SECONDS
|
||||||
|
'';
|
||||||
|
serviceConfig.Type = "simple";
|
||||||
|
};
|
||||||
|
systemd.services."hibernate-after-recovery" = {
|
||||||
|
description = "Hibernates after a suspend recovery due to timeout";
|
||||||
|
wantedBy = ["suspend.target"];
|
||||||
|
after = ["systemd-suspend.service"];
|
||||||
|
environment = hibernateEnvironment;
|
||||||
|
script = ''
|
||||||
|
curtime=$(date +%s)
|
||||||
|
sustime=$(cat $HIBERNATE_LOCK)
|
||||||
|
rm $HIBERNATE_LOCK
|
||||||
|
if [ $(($curtime - $sustime)) -ge $HIBERNATE_SECONDS ] ; then
|
||||||
|
systemctl hibernate
|
||||||
|
else
|
||||||
|
${pkgs.utillinux}/bin/rtcwake -m no -s 1
|
||||||
|
fi
|
||||||
|
'';
|
||||||
|
serviceConfig.Type = "simple";
|
||||||
|
};
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user