-
-
Save danmou/83079feac22307813178d7f8c456c544 to your computer and use it in GitHub Desktop.
Script to sync Taskwarrior after each operation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# 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 sys | |
import json | |
import subprocess | |
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 | |
subprocess.Popen(["task", "rc.hooks=0", "rc.verbose=nothing", "sync"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, stdin=subprocess.PIPE) | |
sys.exit(0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment