From a1bae69d54bfebbdb99c4beb644ebc755a75da24 Mon Sep 17 00:00:00 2001 From: lonkaars Date: Tue, 12 Mar 2024 19:44:04 +0100 Subject: add some example plugins --- plugins/notify | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100755 plugins/notify (limited to 'plugins/notify') diff --git a/plugins/notify b/plugins/notify new file mode 100755 index 0000000..24565ec --- /dev/null +++ b/plugins/notify @@ -0,0 +1,45 @@ +#!/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 + -- cgit v1.2.3