Remote run skill, mu4e change
This commit is contained in:
+1
-1
Submodule azos-core updated: ca609ac0d2...e2110b49d8
@@ -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
|
||||
'';
|
||||
})
|
||||
];
|
||||
|
||||
@@ -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`
|
||||
@@ -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 =
|
||||
|
||||
Reference in New Issue
Block a user