Skip to content

Commit

Permalink
FIX/circadian.el: ensure a single timer + timer is always set
Browse files Browse the repository at this point in the history
  • Loading branch information
guidoschmidt committed Apr 28, 2024
1 parent 12c181d commit 0ec8b12
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions circadian.el
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,8 @@ set and and sort the final list by time."

(defun circadian-schedule()
"Schedule the next timer for circadian."
(if (not (equal nil circadian-next-timer))
(cancel-timer circadian-next-timer))
(random (format-time-string "%H:%M" (decode-time)))
(let* ((themes (circadian-themes-parse))
(now (circadian-now-time))
Expand All @@ -183,19 +185,17 @@ set and and sort the final list by time."
(next-time (circadian-encode-time
(cl-first (cl-first next-entry))
(cl-second (cl-first next-entry)))))
(if (equal nil circadian-next-timer)
(progn
(setq circadian-next-timer
(run-at-time
next-time
nil
#'circadian-enable-theme next-theme))
(if circadian-verbose
(message "[circadian.el] → Next theme %s @ %s"
(if (listp next-theme)
(concat "one of " (format "%s" next-theme))
next-theme)
(format-time-string "%H:%M:%S %Z" next-time)))))))
(setq circadian-next-timer
(run-at-time
next-time
nil
#'circadian-enable-theme next-theme))
(if circadian-verbose
(message "[circadian.el] → Next theme %s @ %s"
(if (listp next-theme)
(concat "one of " (format "%s" next-theme))
next-theme)
(format-time-string "%H:%M:%S %Z" next-time)))))

;; --- Sunset-sunrise
(defun circadian-frac-to-time (f)
Expand Down

0 comments on commit 0ec8b12

Please sign in to comment.