diff --git a/modules/hardware/common/qemu.nix b/modules/hardware/common/qemu.nix index d9a02c018..4ec2963d1 100644 --- a/modules/hardware/common/qemu.nix +++ b/modules/hardware/common/qemu.nix @@ -24,9 +24,6 @@ in ghaf.qemu.guivm = optionalAttrs (hasAttr "hardware" config.ghaf) { microvm.qemu.extraArgs = [ - # Button - "-device" - "button" # Battery "-device" "battery" diff --git a/modules/host/default.nix b/modules/host/default.nix index 5d2413b27..f2a54e2f2 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" ]; + }; }