trailblazer: control script updates

This commit is contained in:
Kate 2025-06-22 13:01:07 +02:00
parent 0d5ab0315a
commit 5b81ddeca0
2 changed files with 65 additions and 4 deletions

View file

@ -34,8 +34,7 @@ let
openrgb -d "Corsair Lighting Node Pro" -m direct -z 1 -s 100 -b 100 -c $1
'';
#mqttServer = "fuuka"
mqttServer = "mitsuru";
mqttServer = "192.168.50.124";
commandScript = pkgs.writeScriptBin "trailblazer-command-daemon" ''
#!${pkgs.xonsh}/bin/xonsh
@ -65,6 +64,16 @@ let
print("[I] Everything should be... well, not-shiny, captain!")
elif verb == "power/suspend":
print("[I] Got a 'sleep' request. Dozing.")
${pkgs.mosquitto}/bin/mosquitto_pub -h ${mqttServer} -t trailblazer/power/status -m sleep
systemctl suspend
elif verb == "power/off":
print("[I] Got a 'power off' request. Will I dream?")
${pkgs.mosquitto}/bin/mosquitto_pub -h ${mqttServer} -t trailblazer/power/status -m off
systemctl suspend
elif verb == "monitors/off":
print("[I] Got a 'monitors off' request. Adding DPMS nulls.")
@ -137,7 +146,8 @@ let
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)
${pkgs.mosquitto}/bin/mosquitto_pub -h ${mqttServer} -t trailblazer/monitors/status -m $(cat /sys/class/drm/card1-HDMI-A-1/dpms)
${pkgs.mosquitto}/bin/mosquitto_pub -h ${mqttServer} -t trailblazer/power/status -m on
'';
in
{
@ -177,7 +187,7 @@ in
boot.kernelParams = [
"iommu=on"
"amd_iommu=on"
#"pcie_acs_override=downstream,multifunction"
"xhci_hcd.quirks=270336" # fix random wakeups, maybe?
];
# Enable fingerprint reader.
@ -246,6 +256,8 @@ in
virtualisation.docker.enable = true;
users.users.deprekated.extraGroups = [ "docker" ];
# Fix XHCI suprious wakeups.
#
# Trailblazer remote service (allows trailblazer things to be controlled via Home Assistant.
#
@ -270,6 +282,54 @@ in
script = "${statusScript}/bin/trailblazer-status-daemon";
};
systemd.services.suspend_notify = {
description = "trailblazer sleep notifier";
# Start once we're online.
wantedBy = [ "suspend.target" ];
wants = [ "network-online.target" ];
after = [ "network-online.target" ];
before = [ "suspend.target" ];
script = "${pkgs.mosquitto}/bin/mosquitto_pub -h ${mqttServer} -t trailblazer/power/status -m sleep";
};
systemd.services.resume_notify = {
description = "trailblazer wake notifier";
# Start once we're online.
wantedBy = [ "suspend.target" ];
wants = [ "network-online.target" ];
after = [ "network-online.target" "suspend.target" ];
script = "${pkgs.mosquitto}/bin/mosquitto_pub -h ${mqttServer} -t trailblazer/power/status -m on";
};
systemd.services.poweroff_notify = {
description = "trailblazer shutdown notifier";
# Start once we're online.
wantedBy = [ "shutdown.target" ];
wants = [ "network-online.target" ];
after = [ "network-online.target" ];
before = [ "shutdown.target" ];
script = "${pkgs.mosquitto}/bin/mosquitto_pub -h ${mqttServer} -t trailblazer/power/status -m shutdown";
};
systemd.services.poweron_notify = {
description = "trailblazer wake notifier";
# Start once we're online.
wantedBy = [ "suspend.target" ];
wants = [ "network-online.target" ];
after = [ "network-online.target" ];
script = "${pkgs.mosquitto}/bin/mosquitto_pub -h ${mqttServer} -t trailblazer/power/status -m on";
};
#
# Let trailblazer share its GPS with the house devices.
#

View file

@ -56,6 +56,7 @@ with pkgs;
# Utils.
_1password-cli
age
age-plugin-yubikey
agenix.agenix
atool
bat