From f6c607e6a350eea8d5b7cfe20f9fe47317d03aee Mon Sep 17 00:00:00 2001 From: Alan Pearce Date: Mon, 16 Nov 2015 16:38:20 +0100 Subject: Emacs: Change themes based on sunlight --- tag-emacs/emacs.d/init.org | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) 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 -- cgit 1.4.1