diff options
author | Gregor Kleen <gkleen@yggdrasil.li> | 2017-03-27 18:14:49 +0200 |
---|---|---|
committer | Gregor Kleen <gkleen@yggdrasil.li> | 2017-03-27 18:14:49 +0200 |
commit | 575a664ee93433b6c3c0d64ea241bf9f6afbeed3 (patch) | |
tree | 2cfb621d10d9d0fddd74d1c7071db8ced658635d | |
parent | fc5ebefef9f331ce7f9cc354709c27372fea4ac6 (diff) | |
download | nixos-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
-rw-r--r-- | hel.nix | 23 |
1 files changed, 23 insertions, 0 deletions
@@ -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 | ||