diff options
author | Erich Eckner <git@eckner.net> | 2022-01-27 12:23:37 +0100 |
---|---|---|
committer | Erich Eckner <git@eckner.net> | 2022-01-27 12:23:37 +0100 |
commit | 95ba90e3a78082e69488958adf104129bae49529 (patch) | |
tree | b086f1b54c7dd13e3c356429495769eeee4ff528 /watch-calendars | |
parent | ef1535e50e79addc11764d5525728f8bb9fe697e (diff) | |
download | khal-extras-95ba90e3a78082e69488958adf104129bae49529.tar.xz |
watch-calendars: only run once
Diffstat (limited to 'watch-calendars')
-rwxr-xr-x | watch-calendars | 10 |
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 \ |