#!/bin/sh [ "$1" = "info" ] && echo "run the notification daemon" && exit 2 . "$core_path/lib" runtime_dir="$XDG_RUNTIME_DIR/$progname" mkdir -p "$runtime_dir" notify_file="$runtime_dir/notify" pid_file="$runtime_dir/pid" [ -e "$pid_file" ] && err "$pid_file exists! use \`kill $(cat "$pid_file")\` to stop the other daemon" echo "$$" > "$pid_file" update() { unset original_state remaining running . "$core_path/update" touch "$notify_file" } update watch_pid=0 cleanup() { trap - TERM rm -f "$pid_file" } trap cleanup INT TERM EXIT while inotifywait -qq -e modify "$POMODORO_STATE_PATH/primary" ; do update if [ $running -eq 1 ] ; then if [ $watch_pid = 0 ] ; then while :; do update & sleep 1 done & watch_pid=$! fi else kill -- $watch_pid 2> /dev/null watch_pid=0 fi done