From 692fa8cd209f9d4411ce90520c203cb9fef3898c Mon Sep 17 00:00:00 2001 From: Antoine Martin Date: Thu, 22 Feb 2024 18:36:59 +0100 Subject: [PATCH] home: i3bar: setup restic backup status "LED" --- home/x/i3bar.nix | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/home/x/i3bar.nix b/home/x/i3bar.nix index a5bd981..580b65e 100644 --- a/home/x/i3bar.nix +++ b/home/x/i3bar.nix @@ -91,6 +91,22 @@ in { chip = cfg.temperature.chip; inputs = cfg.temperature.inputs; } + { + block = "custom"; + # TODO: get service name programmatically somehow + command = let + systemctl = lib.getExe' pkgs.systemd "systemctl"; + in + pkgs.writeShellScript "check-restic.sh" '' + BACKUP_STATUS=Good + if ${systemctl} is-failed --quiet restic-backups-backblaze.service; then + BACKUP_STATUS=Critical + fi + echo "{\"state\": \"$BACKUP_STATUS\", \"text\": \"Backup\"}" + ''; + json = true; + interval = 60; + } ] ++ ( lists.optionals ((builtins.length cfg.networking.throughput_interfaces) != 0)