#!/bin/zsh LOCK=/tmp/task.lock CONTROL_TASK_UUID='5c847c7e-c7eb-44f6-ad7e-29cc989c8854' action() { TASKS_LENGTH=$(task +ACTIVE export | jq -r '. | length') if [[ $TASKS_LENGTH -eq 0 ]]; then tastart "$CONTROL_TASK_UUUID" LAST_TIMEW_END=$(timew export @2 | jq -r '.[0].end') CURRENT_TIMEW_START=$(timew export @1 | jq -r '.[0].start') if [[ "$LAST_TIMEW_END" != "$CURRENT_TIMEW_START" ]]; then tiend @2 "$CURRENT_TIMEW_START" fi fi } while true; do if [[ -e "$LOCK" ]]; then sleep 1 else action sleep 10 fi done