Update taskwarrior sync setup

This commit is contained in:
2024-09-13 14:17:00 +02:00
parent ed44636981
commit 0fe4662551
8 changed files with 48 additions and 67 deletions

View File

@@ -1,25 +0,0 @@
#!/bin/sh
# Inspired by https://gist.github.com/primeapple/d3d82fbd28e9134d24819dd72430888e
read new_task
source ~/.env
log_file=./sync.log
is_up() {
if ! nc -z $TASKD_SERVER $TASKD_PORT; then
echo "Server is down" >> $log_file
exit 1
fi
}
is_up
date > $log_file
task rc.verbose:nothing sync >> $log_file &
echo $new_task
echo 'on-add'
exit 0

View 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)

View File

@@ -1,26 +0,0 @@
#!/bin/sh
# Inspired by https://gist.github.com/primeapple/d3d82fbd28e9134d24819dd72430888e
read original_task
read modified_task
source ~/.env
log_file=./sync.log
is_up() {
if ! nc -z $TASKD_SERVER $TASKD_PORT; then
echo "Server is down" >> $log_file
exit 1
fi
}
is_up
date > $log_file
task rc.verbose:nothing sync >> $log_file &
echo $modified_task
echo 'on-modify'
exit 0