27 lines
816 B
Nix
27 lines
816 B
Nix
{ den, modules, ... }:
|
|
{
|
|
modules.rfkill-sleep = {
|
|
nixos =
|
|
{ pkgs, ... }:
|
|
{
|
|
# My laptop doesn't like having connectivity when it goes to sleep, it burns through battery
|
|
systemd.services.sleep-rfkill = {
|
|
description = "Custom suspend/resume hook";
|
|
wantedBy = [ "sleep.target" ];
|
|
before = [ "sleep.target" ];
|
|
serviceConfig = {
|
|
Type = "oneshot";
|
|
# Command to run BEFORE system suspends
|
|
ExecStart = "${pkgs.util-linux}/bin/rfkill block all";
|
|
# Command to run AFTER system resumes
|
|
ExecStop = "${pkgs.util-linux}/bin/rfkill unblock all";
|
|
RemainAfterExit = true;
|
|
};
|
|
unitConfig = {
|
|
StopWhenUnneeded = true;
|
|
};
|
|
};
|
|
};
|
|
};
|
|
}
|