summaryrefslogtreecommitdiff
path: root/hel.nix
diff options
context:
space:
mode:
authorGregor Kleen <gkleen@yggdrasil.li>2017-03-27 18:14:49 +0200
committerGregor Kleen <gkleen@yggdrasil.li>2017-03-27 18:14:49 +0200
commit575a664ee93433b6c3c0d64ea241bf9f6afbeed3 (patch)
tree2cfb621d10d9d0fddd74d1c7071db8ced658635d /hel.nix
parentfc5ebefef9f331ce7f9cc354709c27372fea4ac6 (diff)
downloadnixos-575a664ee93433b6c3c0d64ea241bf9f6afbeed3.tar
nixos-575a664ee93433b6c3c0d64ea241bf9f6afbeed3.tar.gz
nixos-575a664ee93433b6c3c0d64ea241bf9f6afbeed3.tar.bz2
nixos-575a664ee93433b6c3c0d64ea241bf9f6afbeed3.tar.xz
nixos-575a664ee93433b6c3c0d64ea241bf9f6afbeed3.zip
Don't suspend hel when on power supply
Diffstat (limited to 'hel.nix')
-rw-r--r--hel.nix23
1 files changed, 23 insertions, 0 deletions
diff --git a/hel.nix b/hel.nix
index f0c95ebf..829f3cc7 100644
--- a/hel.nix
+++ b/hel.nix
@@ -474,5 +474,28 @@
474 systemd.user.services."pulseaudio".enable = lib.mkForce false; 474 systemd.user.services."pulseaudio".enable = lib.mkForce false;
475 systemd.user.services."ssh-agent".enable = lib.mkForce false; 475 systemd.user.services."ssh-agent".enable = lib.mkForce false;
476 systemd.user.sockets."pulseaudio".enable = lib.mkForce false; 476 systemd.user.sockets."pulseaudio".enable = lib.mkForce false;
477
478 systemd.services."prevent-suspend" = {
479 description = "Inhibit handling of lid-switch and sleep";
480
481 path = with pkgs;
482 [ systemd coreutils ];
483
484 script = ''
485 #!{pkgs.stdenv.shell}
486
487 exec systemd-inhibit --what=handle-lid-switch:sleep --why="prevent-suspend.service" --mode=block sleep infinity
488 '';
489
490 serviceConfig = {
491 Type = "simple";
492 };
493 };
494
495 services.udev.path = with pkgs; [ systemd ];
496 services.udev.extraRules = ''
497 SUBSYSTEM=="power_supply", ENV{POWER_SUPPLY_ONLINE}=="0", RUN+="systemctl --no-block start prevent-suspend.service"
498 SUBSYSTEM=="power_supply", ENV{POWER_SUPPLY_ONLINE}=="1", RUN+="systemctl --no-block stop prevent-suspend.service"
499 '';
477} 500}
478 501