aboutsummaryrefslogtreecommitdiff
path: root/plugins/notify
diff options
context:
space:
mode:
authorlonkaars <loek@pipeframe.xyz>2024-03-12 19:44:04 +0100
committerlonkaars <loek@pipeframe.xyz>2024-03-12 19:44:04 +0100
commita1bae69d54bfebbdb99c4beb644ebc755a75da24 (patch)
tree48507d6e3c092ce018e8e1b39887c38d2b296052 /plugins/notify
parent8b0ecac59c4fa1d87167f4c1358c2662be3a63aa (diff)
add some example pluginsHEADmaster
Diffstat (limited to 'plugins/notify')
-rwxr-xr-xplugins/notify45
1 files changed, 45 insertions, 0 deletions
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
+