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 {
|
config = lib.mkIf config.azos.homey-alert.enable {
|
||||||
|
azos.claude.globalSkills.notify = ./notify-skill.md;
|
||||||
|
|
||||||
home.packages = [
|
home.packages = [
|
||||||
(pkgs.writeShellApplication {
|
(pkgs.writeShellApplication {
|
||||||
name = "homey-alert";
|
name = "homey-alert";
|
||||||
@@ -28,24 +30,30 @@
|
|||||||
-t, --title TITLE notification title
|
-t, --title TITLE notification title
|
||||||
-p, --priority PRIO priority: min|low|default|high|urgent (default: default)
|
-p, --priority PRIO priority: min|low|default|high|urgent (default: default)
|
||||||
-T, --tags TAGS comma-separated emoji shortcodes (e.g. warning,rotating_light)
|
-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
|
-h, --help show this help
|
||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
homey-alert "Backup complete"
|
# Local
|
||||||
homey-alert -t "Backup" -p high -T white_check_mark "restic finished"
|
long_cmd && homey-alert -t "Training" -p high -T white_check_mark "done"
|
||||||
echo "done" | homey-alert -t "Job finished"
|
|
||||||
|
# Remote — expands locally, runs on the remote machine
|
||||||
|
ssh user@host "python train.py && \$(homey-alert -r -t 'Training' 'done')"
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
TITLE=""
|
TITLE=""
|
||||||
PRIORITY="default"
|
PRIORITY="default"
|
||||||
TAGS=""
|
TAGS=""
|
||||||
|
PRINT_REMOTE=false
|
||||||
|
|
||||||
while [[ $# -gt 0 ]]; do
|
while [[ $# -gt 0 ]]; do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
-t|--title) TITLE="$2"; shift 2 ;;
|
-t|--title) TITLE="$2"; shift 2 ;;
|
||||||
-p|--priority) PRIORITY="$2"; shift 2 ;;
|
-p|--priority) PRIORITY="$2"; shift 2 ;;
|
||||||
-T|--tags) TAGS="$2"; shift 2 ;;
|
-T|--tags) TAGS="$2"; shift 2 ;;
|
||||||
|
-r|--print-remote) PRINT_REMOTE=true; shift ;;
|
||||||
-h|--help) usage; exit 0 ;;
|
-h|--help) usage; exit 0 ;;
|
||||||
--) shift; break ;;
|
--) shift; break ;;
|
||||||
-*) echo "Unknown option: $1" >&2; usage >&2; exit 1 ;;
|
-*) echo "Unknown option: $1" >&2; usage >&2; exit 1 ;;
|
||||||
@@ -65,17 +73,23 @@
|
|||||||
|
|
||||||
TOKEN="$(pass zakobar-homecenter/ntfy-token)"
|
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 "Authorization: Bearer $TOKEN"
|
||||||
-H "Priority: $PRIORITY"
|
-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")
|
if $PRINT_REMOTE; then
|
||||||
[[ -n "$TAGS" ]] && HEADERS+=(-H "Tags: $TAGS")
|
# Shell-quote each element so the output is safe to embed in SSH commands
|
||||||
|
printf '%q ' "''${CMD[@]}"
|
||||||
curl -sf "''${HEADERS[@]}" \
|
printf '\n'
|
||||||
-d "$MESSAGE" \
|
else
|
||||||
https://ntfy.zakobar.com/alerts
|
"''${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 = {
|
config.flake.modules.homeManager.mail = {
|
||||||
lib,
|
lib,
|
||||||
config,
|
config,
|
||||||
|
pkgs,
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
default_account_params = {
|
default_account_params = {
|
||||||
realName = "Aner Zakobar";
|
realName = "Aner Zakobar";
|
||||||
notmuch.enable = true;
|
|
||||||
mbsync = {
|
mbsync = {
|
||||||
enable = true;
|
enable = true;
|
||||||
create = "maildir";
|
create = "maildir";
|
||||||
@@ -30,14 +30,20 @@
|
|||||||
};
|
};
|
||||||
config = lib.mkIf config.azos.mail.enable {
|
config = lib.mkIf config.azos.mail.enable {
|
||||||
programs = {
|
programs = {
|
||||||
notmuch = {
|
mu.enable = true;
|
||||||
enable = true;
|
|
||||||
hooks = {preNew = "mbsync -a";};
|
|
||||||
};
|
|
||||||
mbsync.enable = true;
|
mbsync.enable = true;
|
||||||
msmtp.enable = true;
|
msmtp.enable = true;
|
||||||
lieer.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;
|
services.lieer.enable = true;
|
||||||
accounts.email.accounts = {
|
accounts.email.accounts = {
|
||||||
gmail =
|
gmail =
|
||||||
|
|||||||
Reference in New Issue
Block a user