summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--lisp/acdw.el18
1 files changed, 12 insertions, 6 deletions
diff --git a/lisp/acdw.el b/lisp/acdw.el index a4e12f1..47df30d 100644 --- a/lisp/acdw.el +++ b/lisp/acdw.el
@@ -37,7 +37,7 @@ the filesystem, unless INHIBIT-MKDIR is non-nil."
37 "If MKDIR is non-nil, the directory is created.\n" 37 "If MKDIR is non-nil, the directory is created.\n"
38 "Defined by `/define-dir'.") 38 "Defined by `/define-dir'.")
39 (let ((file-name (expand-file-name (convert-standard-filename file) 39 (let ((file-name (expand-file-name (convert-standard-filename file)
40 ,name))) 40 ,name)))
41 (when mkdir 41 (when mkdir
42 (make-directory (file-name-directory file-name) :parents)) 42 (make-directory (file-name-directory file-name) :parents))
43 file-name)))) 43 file-name))))
@@ -54,8 +54,11 @@ ARGS."
54 (when msg 54 (when msg
55 (message "%s" msg))))) 55 (message "%s" msg)))))
56 56
57(defun +sunrise-sunset (sunrise-command sunset-command) 57(defun +sunrise-sunset (sunrise-command sunset-command &optional reset)
58 "Run SUNRISE-COMMAND at sunrise, and SUNSET-COMMAND at sunset." 58 "Run SUNRISE-COMMAND at sunrise, and SUNSET-COMMAND at sunset.
59With RESET, this function will call itself with its own
60arguments. That's really only useful within this function
61itself."
59 (let* ((times-regex (rx (* nonl) 62 (let* ((times-regex (rx (* nonl)
60 (: (any ?s ?S) "unrise") " " 63 (: (any ?s ?S) "unrise") " "
61 (group (repeat 1 2 digit) ":" 64 (group (repeat 1 2 digit) ":"
@@ -71,9 +74,12 @@ ARGS."
71 (_m (string-match times-regex ss)) 74 (_m (string-match times-regex ss))
72 (sunrise-time (match-string 1 ss)) 75 (sunrise-time (match-string 1 ss))
73 (sunset-time (match-string 2 ss))) 76 (sunset-time (match-string 2 ss)))
74 (run-at-time sunrise-time (* 60 60 24) sunrise-command) 77 (run-at-time sunrise-time nil sunrise-command)
75 (run-at-time sunset-time (* 60 60 24) sunset-command) 78 (run-at-time sunset-time nil sunset-command)
76 (run-at-time "12:00am" (* 60 60 24) sunset-command))) 79 (run-at-time "12:00am" nil sunset-command)
80 ;; Reset everything at midnight
81 (run-at-time "12:00am" (* 60 60 24)
82 #'sunrise-sunset sunrise-command sunset-command t)))
77 83
78(defun +ensure-after-init (function) 84(defun +ensure-after-init (function)
79 "Ensure FUNCTION runs after init, or now if already initialized. 85 "Ensure FUNCTION runs after init, or now if already initialized.