summaryrefslogtreecommitdiff
path: root/hel.nix
diff options
context:
space:
mode:
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