From 755cb7a95372c5c95719026ca6ed47ff071f94e8 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Mon, 8 Mar 2021 22:40:23 -0600 Subject: uhhhhhhhh... stuff? --- lisp/acdw.el | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'lisp/acdw.el') diff --git a/lisp/acdw.el b/lisp/acdw.el index f564777..2f0fe7d 100644 --- a/lisp/acdw.el +++ b/lisp/acdw.el @@ -30,6 +30,27 @@ Ready for use with `after-focus-change-function'." (when (seq-every-p #'null (mapcar #'frame-focus-state (frame-list))) (apply func args))) +(defun acdw/sunrise-sunset (sunrise-command sunset-command) + "Run commands at sunrise and sunset." + (let* ((times-regex (rx (* nonl) + (: (any ?s ?S) "unrise") " " + (group (repeat 1 2 digit) ":" + (repeat 1 2 digit) + (: (any ?a ?A ?p ?P) (any ?m ?M))) + (* nonl) + (: (any ?s ?S) "unset") " " + (group (repeat 1 2 digit) ":" + (repeat 1 2 digit) + (: (any ?a ?A ?p ?P) (any ?m ?M))) + (* nonl))) + (ss (sunrise-sunset)) + (_m (string-match times-regex ss)) + (sunrise-time (match-string 1 ss)) + (sunset-time (match-string 2 ss))) + (run-at-time sunrise-time (* 60 60 24) sunrise-command) + (run-at-time sunset-time (* 60 60 24) sunset-command) + (run-at-time "12:00am" (* 60 60 24) sunset-command))) + ;;; Directories (think `no-littering') (defvar acdw/dir (expand-file-name @@ -43,7 +64,7 @@ directory." (let ((f (expand-file-name (convert-standard-filename file) acdw/dir))) (when make-directory - (make-directory (file-name-directory file) 'parents)) + (make-directory (file-name-directory f) 'parents)) f)) ;;; Settings -- cgit 1.4.1-21-gabe81