Skip to content

Commit

Permalink
hephaestus: add lid-listener service for autorandr
Browse files Browse the repository at this point in the history
  • Loading branch information
alarsyo committed Feb 6, 2024
1 parent a3687b0 commit 39f44da
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions hosts/hephaestus/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,30 @@
};
};

systemd.services.autorandr-lid-listener = {
wantedBy = ["multi-user.target"];
description = "Listening for lid events to invoke autorandr";

serviceConfig = {
Type = "simple";
ExecStart = let
stdbufExe = lib.getExe' pkgs.coreutils "stdbuf";
libinputExe = lib.getExe' pkgs.libinput "libinput";
grepExe = lib.getExe pkgs.gnugrep;
autorandrExe = lib.getExe pkgs.autorandr;
in
pkgs.writeShellScript "lid-listener.sh" ''
${stdbufExe} -oL ${libinputExe} debug-events |
${grepExe} -E --line-buffered '^[[:space:]-]+event[0-9]+[[:space:]]+SWITCH_TOGGLE[[:space:]]' |
while read line; do
${pkgs.systemd}/bin/systemctl start --no-block autorandr.service
done
'';
Restart = "always";
RestartSec = "30";
};
};

# Configure console keymap
console.keyMap = "us";

Expand Down

0 comments on commit 39f44da

Please sign in to comment.