GothenburgBitFactory / GothenburgBitFactory/taskwarrior

Feature request: Auto sync

Open
#4,017 10 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
6.1k
Forks
423
Avg merge
1d 19h
Merged PRs (30d)
11

Description

Hello, I just started using taskwarrior and I really like!

I think it would be a good idea to have an option to be able to auto-sync tasks. Right now it does say when syncing is needed, but you have to do it manually which seems clunky (i.e., if you forget to do it and you don't have that device available your tasks are stale) and you still have to remember to sync yourself to get changes from other places.

# Proposed solution

Add something like a `rc.sync.auto` option (open to bikeshed) to enable autosync. Maybe it would make sense to also add something like `rc.sync.auto.modify-debounce` and `rc.sync.auto.read-debounce`, to be able to configure some debounce timing to not do an unnecessary amount of requests (even though it's generally very little data).

# Current alternatives

Right now I'm using a couple of hooks to sync on launch and on modify:

```bash
FLAGFILE="/tmp/taskwarrior-needs-sync"
LAST_SYNC="/tmp/taskwarrior-last-sync"
SYNC_INTERVAL=300 # 5 minutes

# Only sync if enough time has passed
time_passed=$(($(date +%s) - $(date -r "$LAST_SYNC" +%s 2>/dev/null || echo 0)))
if [ $time_passed -lt $SYNC_INTERVAL ]; then
exit 0
fi

/nix/store/h3l2d5mmijwffnmpq3fw598x55d6x6cn-taskwarrior-3.4.1/bin/task rc.hooks=off sync > /dev/null 2>&1
touch "$LAST_SYNC"
exit 0
```

```bash
FLAGFILE="/tmp/taskwarrior-needs-sync"
PIDFILE="/tmp/taskwarrior-sync.pid"

# Echo tasks
read original_task
read added_task
echo "$added_task"

# Mark that we need a sync
touch "$FLAGFILE"

# Exit if sync process already running
if [ -f "$PIDFILE" ] && kill -0 $(cat "$PIDFILE") 2>/dev/null; then
exit 0
fi

# Start background sync process
nohup /nix/store/ndyhaygmwxljqqssbcqz7ir0v5b7cjm9-bash-interactive-5.3p3/bin/bash -c '
echo $$ > "'"$PIDFILE"'"
sleep 5
if [ -f "'"$FLAGFILE"'" ]; then
rm "'"$FLAGFILE"'"
'"/nix/store/h3l2d5mmijwffnmpq3fw598x55d6x6cn-taskwarrior-3.4.1/bin/task"' rc.hooks=off sync
fi
rm -f "'"$PIDFILE"'"
' > /dev/null 2>&1

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.