summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAlan Pearce2015-11-16 16:38:20 +0100
committerAlan Pearce2015-11-16 16:38:20 +0100
commitf6c607e6a350eea8d5b7cfe20f9fe47317d03aee (patch)
treec98be8aefd283d08088c8ec9d64d6ac9b4ee921b
parent818df9fc3af1a0f6deb903d262065256938e5676 (diff)
downloadnixfiles-f6c607e6a350eea8d5b7cfe20f9fe47317d03aee.tar.lz
nixfiles-f6c607e6a350eea8d5b7cfe20f9fe47317d03aee.tar.zst
nixfiles-f6c607e6a350eea8d5b7cfe20f9fe47317d03aee.zip
Emacs: Change themes based on sunlight
-rw-r--r--tag-emacs/emacs.d/init.org31
1 files changed, 30 insertions, 1 deletions
diff --git a/tag-emacs/emacs.d/init.org b/tag-emacs/emacs.d/init.org
index af96248e..4dcbe057 100644
--- a/tag-emacs/emacs.d/init.org
+++ b/tag-emacs/emacs.d/init.org
@@ -237,7 +237,8 @@ lot of modes.
 #+BEGIN_SRC emacs-lisp
   (req-package solarized-theme
     :config (progn
-              (load-theme 'solarized-light t)))
+              (load-theme 'solarized-light t t)
+              (load-theme 'solarized-dark t t)))
 #+END_SRC
 
 Colourise colour names in certain types of buffer.  I don’t use this
@@ -837,6 +838,34 @@ Sometimes I want to insert a date or time into a buffer.
     (insert (format-time-string format))))
 #+END_SRC
 
+** Time of Day
+
+#+BEGIN_SRC emacs-lisp
+  (req-package rase
+    :config (progn
+              (defun switch-themes (sun-event &optional first-run)
+                "Switch themes on sunrise and sunset."
+                (if first-run            ; set theme on initialization
+                    (cond ((memq sun-event '(sunrise midday))
+                           (disable-theme 'solarized-dark)
+                           (enable-theme 'solarized-light))
+                          ((memq sun-event '(sunset midnight))
+                           (disable-theme 'solarized-light)
+                           (enable-theme 'solarized-dark)))
+                  (cond ((eq sun-event 'sunrise) ; after initialization deal only
+                         (disable-theme 'solarized-dark) ; with sunrise and sunset
+                         (enable-theme 'solarized-light))
+                        ((eq sun-event 'sunset)
+                         (disable-theme 'solarized-light)
+                         (enable-theme 'solarized-dark)))))
+
+              ;; sign this function to be invoked on sun events
+              (add-hook 'rase-functions 'switch-themes)
+
+              ;; start the run-at-sun-event daemon, invoking hooks immediately
+              (rase-start t)))
+#+END_SRC
+
 * Directories
 
 Dired works quite nicely, but not always in the way I want.  I don’t