#!/usr/bin/bash # This script assumes debounce.sh from # https://github.com/MerkleBros/debounce.sh # is in the path. cd "$(dirname "$0")" || exit if [ ! -d ".venv" ] then python -m venv .venv . .venv/bin/activate pip install -r requirements.txt else . .venv/bin/activate fi name="$(basename "$(basename "$1")" .txt)" echo "Watching $1 and writing to $2/$name.html" { while true do inotifywait -e close_write "$1" >/dev/null echo "TODO file updated." done & { echo "Start." # From https://stackoverflow.com/a/19067658 sleep "$(( $( printf '%s\nnow\n' "tomorrow 00:01" | date -f - +%s- ) 0 ))" while true do echo "Start of day." sleep 1d done }; } | debounce.sh read 5 "./todotxt-to-html.py - \"$name\" < \"$1\" > \"$2/$name.html\""