reddit / emacs

circadian.el switches from "sunrise" to "sunset", but not the other way around. Why?

olivuser · 2022-11-02 07:09
Hej fellows, while \`circadian\` does switch from the "sunrise" to the "sunset" theme, it doesn't do the other way around. Given correct long/lat, the opposite switch does simply not happen (even like 2-3 hours after the sun has risen). Can anyone help me understand why that happens? My configuration: (use-package circadian :config (setq calendar-latitude 50.1) (setq calendar-longitude 8.66) (setq circadian-themes '((:sunrise . modus-operandi) (:sunset . modus-vivendi))) (circadian-setup))
jumper047 · 2022-11-02 08:02
Sounds like that issue - https://github.com/guidoschmidt/circadian.el/issues/25 You can check workaround described in issue, or patch sources by hands - you need this commit https://github.com/guidoschmidt/circadian.el/pull/26/commits/f014110bc663dc2926f3fdc9e63343725c8f7184 I opened pull request with the fix, by it still not approved:(
a-c-d-w · 2022-11-02 21:13
I wrote my own solution `dawn` (https://ttm.sh/0q6.txt) for this, because circadian was being dumb. I don't remember like, anything other than that, but you might find it useful.
ckoneru · 2022-11-03 02:36
Firewall blocks this link.
a-c-d-w · 2022-11-03 03:23
I can paste in a comment once I'm at my computer!
a-c-d-w · 2022-11-03 20:30
;;; dawn.el --- Do things at dawn (and dusk) -*- lexical-binding: t; -*- ;;; Commentary: ;; There is also circadian.el, but it doesn't quite work for me. ;; This code comes mostly from https://gnu.xyz/auto_theme.html, but also ;; somewhere else (which I've forgotten) and my own brain :) ;;; Code: (require 'calendar) (require 'cl-lib) (require 'solar) (defvar dawn--dawn-timer nil "Timer for dawn-command.") (defvar dawn--dusk-timer nil "Timer for dusk-command.") (defvar dawn--reset-timer nil "Timer to reset dawn at midnight.") (defun dawn-encode-time (f) "Encode fractional time F." (let ((hhmm (cl-floor f)) (date (cdddr (decode-time)))) (encode-time (append (list 0 (round (* 60 (cadr hhmm))) (car hhmm) ) date)))) (defun dawn-midnight () "Return the time of the /next/ midnight." (let ((date (cdddr (decode-time)))) (encode-time (append (list 0 0 0 (1+ (car date))) (cdr date))))) (defun dawn-sunrise () "Return the time of today's sunrise." (dawn-encode-time (caar (solar-sunrise-sunset (calendar-current-date))))) (defun dawn-sunset () "Return the time of today's sunset." (dawn-encode-time (caadr (solar-sunrise-sunset (calendar-current-date))))) (defun dawn-schedule (dawn-command dusk-command) "Run DAWN-COMMAND at sunrise, and DUSK-COMMAND at dusk. RESET is an argument for internal use." (let ((dawn (dawn-sunrise)) (dusk (dawn-sunset))) (cond ((or (null calendar-longitude) (null calendar-latitude)) (user-error "`dawn' won't work without setting %s!" (cond ((and (null calendar-longitude) (null calendar-latitude)) "`calendar-longitude' and `calendar-latitude'") ((null calendar-longitude) "`calendar-longitude'") ((null calendar-latitude) "`calendar-latitude'")))) ((time-less-p nil dawn) ;; If it isn't dawn yet, it's still dark. Run DUSK-COMMAND and schedule ;; DAWN-COMMAND and DUSK-COMMAND for later. (funcall dusk-command) (run-at-time dawn nil dawn-command) (run-at-time dusk nil dusk-command)) ((time-less-p nil dusk) ;; If it isn't dusk yet, it's still light. Run DAWN-COMMAND and schedule ;; DUSK-COMMAND. (funcall dawn-command) (run-at-time dusk nil dusk-command)) (t ;; Otherwise, it's past dusk, so run DUSK-COMMAND. (funcall dusk-command))) ;; Schedule a reset at midnight, to re-calculate dawn/dusk times. ;(unless reset) (run-at-time (dawn-midnight) nil #'dawn-schedule dawn-command dusk-command))) (provide 'dawn) ;;; dawn.el ends here
ckoneru · 2022-11-05 04:43
Thanks