From be7b577b3b377f608831e05b25efb723aa8deb65 Mon Sep 17 00:00:00 2001 From: Daniel Fichtinger Date: Mon, 16 Jun 2025 21:20:52 -0400 Subject: [PATCH] AutoYADM commit: 2025-06-16 21:20:52 --- .config/task/.gitignore | 1 + .config/task/.ignore | 1 + .config/task/README.md | 3 ++ .config/task/hooks/on-exit-sync.sh | 47 ++++++++++++++++++++++++++++++ .config/task/taskrc.ini | 10 +++++++ .config/yadm/tracked | 2 ++ .taskrc##template | 3 ++ 7 files changed, 67 insertions(+) create mode 100644 .config/task/.gitignore create mode 100644 .config/task/.ignore create mode 100644 .config/task/README.md create mode 100755 .config/task/hooks/on-exit-sync.sh create mode 100644 .config/task/taskrc.ini diff --git a/.config/task/.gitignore b/.config/task/.gitignore new file mode 100644 index 00000000..38a9ae66 --- /dev/null +++ b/.config/task/.gitignore @@ -0,0 +1 @@ +secret.ini diff --git a/.config/task/.ignore b/.config/task/.ignore new file mode 100644 index 00000000..38a9ae66 --- /dev/null +++ b/.config/task/.ignore @@ -0,0 +1 @@ +secret.ini diff --git a/.config/task/README.md b/.config/task/README.md new file mode 100644 index 00000000..e31dbb54 --- /dev/null +++ b/.config/task/README.md @@ -0,0 +1,3 @@ +To set up: + +- copy `.taskrc` to homedir and set the correct client_id and encryption_secret diff --git a/.config/task/hooks/on-exit-sync.sh b/.config/task/hooks/on-exit-sync.sh new file mode 100755 index 00000000..76f6ad59 --- /dev/null +++ b/.config/task/hooks/on-exit-sync.sh @@ -0,0 +1,47 @@ +#!/bin/sh + +n=0 +while IFS= read -r _; do + n=$((n + 1)) +done + +if [ "$n" -gt 0 ]; then + { + lockfile="$HOME/.task/sync_hook.lock" + errfile="$HOME/.task/sync_hook.err" + lerrfile="$HOME/.task/sync_hook.errl" + logfile="$HOME/.task/sync_hook.log" + + flock "$lockfile" sh -c ' + task sync >>"$1" 2>"$2" + status=$? + if [ "$status" -ne 0 ]; then + echo "Taskwarrior sync failed at $(date)" >>"$2" + + if command -v sendmail >/dev/null 2>&1; then + { + echo "To: daniel@ficd.ca" + echo "From: daniel@ficd.ca" + echo "Subject: Taskwarrior Sync Failed on $(hostname)" + echo "Date: $(date -R)" + echo "" + echo "task sync failed at $(date)" + echo "" + cat "$2" + } | sendmail -t + fi + + cat "$2" >>"$3" + + if command -v notify-send >/dev/null 2>&1; then + notify-send --urgency=critical "taskwarrior sync failed" + fi + + exit 1 + fi + ' sh "$logfile" "$lerrfile" "$errfile" "$(hostname)" + } >/dev/null 2>&1