Add 'dots/' from commit 'f64b634dd8fbb2c8a2898c3b9d0acc9452e4d966'
git-subtree-dir: dots git-subtree-mainline:2ad98cde17git-subtree-split:f64b634dd8
This commit is contained in:
32
dots/.local/share/task/hooks/on-exit.sync.py
Executable file
32
dots/.local/share/task/hooks/on-exit.sync.py
Executable file
@@ -0,0 +1,32 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# Source: <https://gist.github.com/danmou/83079feac22307813178d7f8c456c544>
|
||||
|
||||
# This hooks script syncs task warrior to the configured task server without blocking.
|
||||
# The on-exit event is triggered once, after all processing is complete.
|
||||
|
||||
# Make sure hooks are enabled and this hook script is executable.
|
||||
# Run `task diag` for diagnostics on the hook.
|
||||
|
||||
import json
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
try:
|
||||
tasks = json.loads(sys.stdin.readline())
|
||||
except:
|
||||
# No input
|
||||
pass
|
||||
|
||||
# Call the `sync` command
|
||||
# hooks=0 ensures that the sync command doesn't call the on-exit hook
|
||||
# verbose=nothing sets the verbosity to print nothing at all
|
||||
|
||||
ps_1 = subprocess.Popen(
|
||||
["task", "rc.hooks=0", "sync"],
|
||||
stdin=subprocess.PIPE,
|
||||
stdout=subprocess.DEVNULL,
|
||||
stderr=subprocess.DEVNULL,
|
||||
)
|
||||
|
||||
sys.exit(0)
|
||||
12
dots/.local/share/task/scripts/sync-and-notify.sh
Executable file
12
dots/.local/share/task/scripts/sync-and-notify.sh
Executable file
@@ -0,0 +1,12 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Redirect both stdout and stderr to notify-send as is, but set
|
||||
# urgency to critical if the command fails
|
||||
output="$(task rc.hooks=0 sync 2>&1)"
|
||||
ret=$?
|
||||
if [ $ret -ne 0 ]; then
|
||||
urgency=critical
|
||||
else
|
||||
urgency=normal
|
||||
fi
|
||||
notify-send -u $urgency "Taskwarrior sync" "$output"
|
||||
Reference in New Issue
Block a user