From 9c64e1513eea092cc1c9b7c1f704f838a298cf46 Mon Sep 17 00:00:00 2001 From: Aner Zakobar Date: Sun, 6 Sep 2026 11:49:54 +0300 Subject: [PATCH] Remote run skill, mu4e change --- azos-core | 2 +- features/homey-alert/default.nix | 48 ++++++++++++++++++---------- features/homey-alert/notify-skill.md | 48 ++++++++++++++++++++++++++++ features/mail/default.nix | 16 +++++++--- 4 files changed, 91 insertions(+), 23 deletions(-) create mode 100644 features/homey-alert/notify-skill.md diff --git a/azos-core b/azos-core index ca609ac..e2110b4 160000 --- a/azos-core +++ b/azos-core @@ -1 +1 @@ -Subproject commit ca609ac0d297a2613bb7c7645190f0e788bf573b +Subproject commit e2110b49d820f2844f2becb5b032c9ffad0215fa diff --git a/features/homey-alert/default.nix b/features/homey-alert/default.nix index c3783f8..674f4fb 100644 --- a/features/homey-alert/default.nix +++ b/features/homey-alert/default.nix @@ -12,6 +12,8 @@ }; config = lib.mkIf config.azos.homey-alert.enable { + azos.claude.globalSkills.notify = ./notify-skill.md; + home.packages = [ (pkgs.writeShellApplication { name = "homey-alert"; @@ -28,28 +30,34 @@ -t, --title TITLE notification title -p, --priority PRIO priority: min|low|default|high|urgent (default: default) -T, --tags TAGS comma-separated emoji shortcodes (e.g. warning,rotating_light) + -r, --print-remote print the curl command instead of running it + (for pasting into SSH commands to remote machines) -h, --help show this help Examples: - homey-alert "Backup complete" - homey-alert -t "Backup" -p high -T white_check_mark "restic finished" - echo "done" | homey-alert -t "Job finished" + # Local + long_cmd && homey-alert -t "Training" -p high -T white_check_mark "done" + + # Remote — expands locally, runs on the remote machine + ssh user@host "python train.py && \$(homey-alert -r -t 'Training' 'done')" EOF } TITLE="" PRIORITY="default" TAGS="" + PRINT_REMOTE=false while [[ $# -gt 0 ]]; do case "$1" in - -t|--title) TITLE="$2"; shift 2 ;; - -p|--priority) PRIORITY="$2"; shift 2 ;; - -T|--tags) TAGS="$2"; shift 2 ;; - -h|--help) usage; exit 0 ;; - --) shift; break ;; - -*) echo "Unknown option: $1" >&2; usage >&2; exit 1 ;; - *) break ;; + -t|--title) TITLE="$2"; shift 2 ;; + -p|--priority) PRIORITY="$2"; shift 2 ;; + -T|--tags) TAGS="$2"; shift 2 ;; + -r|--print-remote) PRINT_REMOTE=true; shift ;; + -h|--help) usage; exit 0 ;; + --) shift; break ;; + -*) echo "Unknown option: $1" >&2; usage >&2; exit 1 ;; + *) break ;; esac done @@ -65,17 +73,23 @@ TOKEN="$(pass zakobar-homecenter/ntfy-token)" - HEADERS=( + # Build the curl invocation as an array — single source of truth for both modes + CMD=( + curl -sf -H "Authorization: Bearer $TOKEN" -H "Priority: $PRIORITY" ) + [[ -n "$TITLE" ]] && CMD+=(-H "Title: $TITLE") + [[ -n "$TAGS" ]] && CMD+=(-H "Tags: $TAGS") + CMD+=(-d "$MESSAGE" https://ntfy.zakobar.com/alerts) - [[ -n "$TITLE" ]] && HEADERS+=(-H "Title: $TITLE") - [[ -n "$TAGS" ]] && HEADERS+=(-H "Tags: $TAGS") - - curl -sf "''${HEADERS[@]}" \ - -d "$MESSAGE" \ - https://ntfy.zakobar.com/alerts + if $PRINT_REMOTE; then + # Shell-quote each element so the output is safe to embed in SSH commands + printf '%q ' "''${CMD[@]}" + printf '\n' + else + "''${CMD[@]}" + fi ''; }) ]; diff --git a/features/homey-alert/notify-skill.md b/features/homey-alert/notify-skill.md new file mode 100644 index 0000000..cf48109 --- /dev/null +++ b/features/homey-alert/notify-skill.md @@ -0,0 +1,48 @@ +# Homey Alert — sending ntfy notifications when tasks finish + +Use `homey-alert` to push notifications to Aner's homelab ntfy server when long tasks complete. + +## When to use proactively + +When running (or suggesting) a command that will take more than ~30 seconds — training runs, +builds, deploys, downloads, test suites — append a notification automatically. Don't wait to +be asked. + +## Local commands + +Append after the command so it fires on success only (`&&`) or always (`;`): + +```bash +# Notify on success only +long_cmd && homey-alert "Task done" + +# Always notify (even on failure) — prefer this for deploys/training +long_cmd; homey-alert -t "Training" -p high -T "$([ $? -eq 0 ] && echo white_check_mark || echo x)" "Exited $?" +``` + +## Remote commands (SSH / training machines) + +Remote machines don't have `homey-alert`. Use `-r`/`--print-remote` to get a self-contained +`curl` command with the token already embedded. The `$(...)` expands **locally**; the resulting +command string is what the remote machine executes. + +```bash +ssh user@host "python train.py && $(homey-alert -r -t 'Training' -p high -T white_check_mark 'Model finished')" +``` + +The remote machine only needs `curl` (universally available). + +## Flags + +| Flag | Short | Values / notes | +|------|-------|----------------| +| `--title TITLE` | `-t` | Notification title | +| `--priority PRIO` | `-p` | `min` / `low` / `default` / `high` / `urgent` | +| `--tags TAGS` | `-T` | Comma-separated emoji shortcodes: `white_check_mark`, `x`, `warning`, `rotating_light`, `tada` | +| `--print-remote` | `-r` | Print curl command instead of running (embed token locally, run remotely) | + +## Choosing priority and tags + +- Routine completion (backup, build): `default` priority, `white_check_mark` +- Training / long job: `high` priority, `white_check_mark` on success / `x` on failure +- Something broke: `urgent` priority, `rotating_light` diff --git a/features/mail/default.nix b/features/mail/default.nix index 702862e..dd831a2 100644 --- a/features/mail/default.nix +++ b/features/mail/default.nix @@ -2,11 +2,11 @@ config.flake.modules.homeManager.mail = { lib, config, + pkgs, ... }: let default_account_params = { realName = "Aner Zakobar"; - notmuch.enable = true; mbsync = { enable = true; create = "maildir"; @@ -30,14 +30,20 @@ }; config = lib.mkIf config.azos.mail.enable { programs = { - notmuch = { - enable = true; - hooks = {preNew = "mbsync -a";}; - }; + mu.enable = true; mbsync.enable = true; msmtp.enable = true; lieer.enable = true; }; + home.activation.muInit = lib.hm.dag.entryAfter ["writeBoundary"] '' + if [ ! -d "$HOME/.cache/mu" ]; then + $DRY_RUN_CMD ${pkgs.mu}/bin/mu init \ + --maildir="$HOME/Mail" \ + --my-address=aner@zakobar.com \ + --my-address=anerisgreat@gmail.com \ + --my-address=anerz@post.bgu.ac.il + fi + ''; services.lieer.enable = true; accounts.email.accounts = { gmail =