trailblazer: update command script to send status, too

This commit is contained in:
Kate 2025-06-12 02:15:11 +02:00
parent 24cf33066e
commit c9438566c8

View file

@ -65,7 +65,36 @@ let
print("[I] Everything should be... well, not-shiny, captain!")
if verb == "lights/ledsoff":
elif verb == "monitors/off":
print("[I] Got a 'monitors off' request. Adding DPMS nulls.")
# Turn off monitors for any X11 anything.
for auth in g`/tmp/xauth_*`:
print(f"[I] Turning off monitors on X instance with auth file {auth}.")
!(env DISPLAY=:0 XAUTHORITY=@(auth) xset dpms force off)
# Turn off monitors on each niri session,
sockets = g`/var/run/user/1000/niri*.sock`
for socket in sockets:
print(f"[I] Turning off monitors on niri instance {socket}.")
!(env NIRI_SOCKET=@(socket) niri msg action power-off-monitors)
elif verb == "monitors/on":
print("[I] Got a 'monitors on' request. Removing DPMS nulls.")
# Turn off monitors for any X11 anything.
for auth in g`/tmp/xauth_*`:
print(f"[I] Turning on monitors on X instance with auth file {auth}.")
!(env DISPLAY=:0 XAUTHORITY=@(auth) xset dpms force on)
# Turn off monitors on each niri session,
sockets = g`/var/run/user/1000/niri*.sock`
for socket in sockets:
print(f"[I] Turning on monitors on niri instance {socket}.")
!(env NIRI_SOCKET=@(socket) niri msg action power-on-monitors)
elif verb == "lights/ledsoff":
print("[I] Turning off RGB leds.")
!(${ledOffScript}/bin/ledsoff)
@ -102,6 +131,14 @@ let
print("----------------------------")
'';
statusScript = pkgs.writeScriptBin "trailblazer-status-daemon" ''
#!${pkgs.xonsh}/bin/xonsh
print("[I] Trailblazer status service started. Updating every 10s.")
while True:
sleep 10
mosquitto_pub -h mitsuru -t trailblazer/monitors/status -m $(cat /sys/class/drm/card1-HDMI-A-1/dpms)
'';
in
{
system.stateVersion = "23.11";
@ -221,6 +258,16 @@ in
script = "${commandScript}/bin/trailblazer-command-daemon";
};
systemd.services.trailblazer-status = {
description = "trailblazer status service";
# Start once we're online.
wantedBy = [ "default.target" ];
wants = [ "network-online.target" ];
after = [ "network-online.target" ];
script = "${statusScript}/bin/trailblazer-status-daemon";
};
#
# Let trailblazer share its GPS with the house devices.