guidoschmidt / circadian.el

Theme-switching for Emacs based on daytime
https://guidoschmidt.github.io/circadian.el
MIT License
169 stars 8 forks source link

circadian-themes switch interval problem #23

Closed emacle closed 3 months ago

emacle commented 3 years ago
(use-package circadian
  :config
  (setq circadian-themes '(
               ("8:00" . doom-outrun-electric)
               ("9:00" . alect-dark-alt)
               ("10:00" . misterioso)
               ("11:00" . doom-snazzy)
               ("12:00" . birds-of-paradise-plus)
               ("13:00" . doom-oceanic-next)
               ("14:00" . wombat)
               ("15:00" . wheatgrass)
               ("16:00" . doom-palenight)
               ("17:00" . doom-nova)
               ("18:00" . doom-acario-dark)
               (:sunset  . github-modern) ; 19:05
               ("21:00" . adwaita)
               ("22:00" . dichromacy)
               ("23:00" . doom-acario-light)
               ))
  (circadian-setup))

At current time 2020-08-25 13:10:00 . I eval last config then the theme doom-oceanic-next enabled, but when I checked timer-list variable

( [nil 24388 40706 309167 nil undo-auto--boundary-timer nil nil 0]
  [nil 24388 40737 26724 60 ac-clear-variables-every-minute nil nil 0]
  [nil 24389 6496 0 nil circadian-activate-latest-theme nil nil 0])
;; (format-time-string
;;  "%Y-%m-%d %H:%M:%S %z"
;;  '(24389 6496 0)
;; )
;; => "2020-08-25 22:00:00 +0800"  run circadian-activate-latest-theme function

I saw the circadian-activate-latest-theme function next run at 2020-08-25 22:00:00

but it should not be running at 14:00 (for wombat theme) as circadian-themes variable defined

emacle commented 3 years ago

change circadian--encode-time function delete encode-time zone param to keep decode-time and encode-time zone the same. solved!

 (defun circadian--encode-time (hour min)
  "Encode HOUR hours and MIN minutes into a valid format for `run-at-time'."
  (let ((now (decode-time)))
    (let ((day (nth 3 now))
          (month (nth 4 now))
          (year (nth 5 now)))
      (encode-time 0 min hour day month year))))
guidoschmidt commented 3 months ago

@emacle Do you have calendar-latitude and calendar-longitude set in your config?

You can find your places lat/long coordinates e.g. via www.latlong.net and then set this before using circadian:

(setq calendar-latitude $YOUR_LAT_VALUE)
(setq calendar-longitude $YOUR_LNG_VALUE)