diff --git a/taskwarrior/.local/share/task/hooks/on-exit.sync-to-server-silent.py b/taskwarrior/.local/share/task/hooks/on-exit.sync-to-server-silent.py new file mode 100755 index 0000000..f444c69 --- /dev/null +++ b/taskwarrior/.local/share/task/hooks/on-exit.sync-to-server-silent.py @@ -0,0 +1,29 @@ +#!/usr/bin/env python3 + +# From: https://gist.github.com/varunagrawal/2b93c5dc721520ff6876e940c420ab05 +# This hooks script syncs task warrior to the configured task server. +# 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 sys +import json +import subprocess + +try: + tasks = json.loads(sys.stdin.readline()) +except: + # No input + sys.exit(0) + +# no tasks to work through, don't error +if len(tasks) <= 0: + sys.exit(0) + +# 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 +subprocess.Popen(["task", "rc.verbose=nothing", "rc.hooks=0", "sync"], close_fds=True) + +sys.exit(0) diff --git a/taskwarrior/.local/share/task/hooks/on-exit.sync-to-server.sh b/taskwarrior/.local/share/task/hooks/on-exit.sync-to-server.sh deleted file mode 100755 index bf656d9..0000000 --- a/taskwarrior/.local/share/task/hooks/on-exit.sync-to-server.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env sh -# This hooks script syncs task warrior to the configured task server. -# The on-exit event is triggered once, after all processing is complete. - -# Make sure hooks are enabled - -# Count the number of tasks modified -n=0 -while read -r REPLY; do - n=$((n + 1)) -done - -if [ $n -gt 0 ]; then - SAVELOC="${XDG_DATA_HOME}/task" - task sync >>"${SAVELOC:-~/.task}/sync_hook.log" & -fi