diff --git a/modules/host/default.nix b/modules/host/default.nix index 5d2413b279..f2a54e2f2d 100644 --- a/modules/host/default.nix +++ b/modules/host/default.nix @@ -3,7 +3,7 @@ # # Modules that should be only imported to host # -{ lib, ... }: +{ lib, pkgs, ... }: { networking.hostName = lib.mkDefault "ghaf-host"; @@ -15,4 +15,27 @@ # To push logs to central location ../common/logging/client.nix ]; + + # Adding below systemd services to save power by turning off display when system is suspended / lid close + systemd.services.display-suspend = { + enable = true; + description = "Display Suspend Service"; + serviceConfig = { + Type = "oneshot"; + ExecStart = ''${pkgs.sshpass}/bin/sshpass -p ghaf ${pkgs.openssh}/bin/ssh -o StrictHostKeyChecking=no ghaf@gui-vm-debug WAYLAND_DISPLAY=/run/user/1000/wayland-0 wlopm --off \* ''; + }; + wantedBy = [ "sleep.target" ]; + before = [ "sleep.target" ]; + }; + + systemd.services.display-resume = { + enable = true; + description = "Display Resume Service"; + serviceConfig = { + Type = "oneshot"; + ExecStart = ''${pkgs.sshpass}/bin/sshpass -p ghaf ${pkgs.openssh}/bin/ssh -o StrictHostKeyChecking=no ghaf@gui-vm-debug WAYLAND_DISPLAY=/run/user/1000/wayland-0 wlopm --on \* ''; + }; + wantedBy = [ "suspend.target" ]; + after = [ "suspend.target" ]; + }; }