Skip to content

Commit

Permalink
Turn off the display when system is suspended on lid close
Browse files Browse the repository at this point in the history
This patch is adding two systemd services.
On suspend we turn off the display of gui-vm and on
resume we turn on the display back. This will help to
save system power when system system is suspended or lid
is closed.

Signed-off-by: Vunny Sodhi <vunny.sodhi@unikie.com>
  • Loading branch information
vunnyso committed Sep 11, 2024
1 parent c54e0f4 commit 665d9c7
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion modules/host/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#
# Modules that should be only imported to host
#
{ lib, ... }:
{ lib, pkgs, ... }:
{
networking.hostName = lib.mkDefault "ghaf-host";

Expand All @@ -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" ];
};
}

0 comments on commit 665d9c7

Please sign in to comment.