/Users/yaesposi/y/her.esy.fun/src/posts/0014-change-emacs-theme-automatically/index.org

This commit is contained in:
Yann Esposito (Yogsototh) 2020-09-22 07:57:55 +02:00
parent 4ce8b8193e
commit a702bee433
Signed by untrusted user who does not match committer: yogsototh
GPG Key ID: 7B19A4C650D59646
1 changed files with 27 additions and 1 deletions

View File

@ -13,4 +13,30 @@ One would be to sync with the sun using the current location.
There is an emacs package for that.
It's called [[https://github.com/hadronzoo/theme-changer][theme-changer]] which at the timme of writing those lines is
asking for a new maintainer.
This theme changer is very elegant because like macOS use the coordinate
This theme changer is very elegant because like macOS use the location to
determine if it is day or night.
But I wanted to have more themes from morning to night:
1. early morning: deep yellow (gruvbox-light),
2. morning: light yellow (solarized-light),
3. day: grey/blueish during the day (nord-light),
4. evening: then back to yellow during
5. night: dark theme (oceanic-next)
#+BEGIN_SRC elisp
(defun y/update-theme ()
"depending on time use different theme"
;; very early => gruvbox-light, solarized-light, nord-light
(let* ((hour (nth 2 (decode-time (current-time))))
(theme (cond ((<= 7 hour 8) 'doom-gruvbox-light)
((= 9 hour) 'doom-solarized-light)
((<= 10 hour 16) 'doom-nord-light)
((<= 17 hour 18) 'doom-gruvbox-light)
((<= 19 hour 22) 'doom-oceanic-next)
(t 'doom-laserwave))))
(when (not (equal doom-theme theme))
(setq doom-theme theme)
(load-theme doom-theme))))
(y/update-theme)
#+END_SRC