From 95ba90e3a78082e69488958adf104129bae49529 Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Thu, 27 Jan 2022 12:23:37 +0100 Subject: watch-calendars: only run once --- watch-calendars | 10 ++++++++++ 1 file changed, 10 insertions(+) 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 \ -- cgit v1.2.3-70-g09d2