summaryrefslogtreecommitdiff
path: root/watch-calendars
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2022-01-27 12:23:37 +0100
committerErich Eckner <git@eckner.net>2022-01-27 12:23:37 +0100
commit95ba90e3a78082e69488958adf104129bae49529 (patch)
treeb086f1b54c7dd13e3c356429495769eeee4ff528 /watch-calendars
parentef1535e50e79addc11764d5525728f8bb9fe697e (diff)
downloadkhal-extras-95ba90e3a78082e69488958adf104129bae49529.tar.xz
watch-calendars: only run once
Diffstat (limited to 'watch-calendars')
-rwxr-xr-xwatch-calendars10
1 files changed, 10 insertions, 0 deletions
diff --git a/watch-calendars b/watch-calendars
index cf9eb21..0c74f89 100755
--- a/watch-calendars
+++ b/watch-calendars
@@ -1,6 +1,16 @@
#!/bin/bash
+lock_file=/tmp/watch-calendars.lock
+
if [ $# -eq 0 ]; then
+ if [ -r "${lock_file}" ] \
+ && kill -0 "$(cat "${lock_file}")"; then
+ exit
+ fi
+
+ echo $$ >"${lock_file}"
+ trap 'rm "${lock_file:?}"' EXIT
+
find ~/.local/share/khal/calendars \
-mindepth 1 \
-maxdepth 1 \