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 ee9131b commit 662cf77
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions hosts/hephaestus/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,29 @@
};
};

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 662cf77

Please sign in to comment.