One thing I kind of like is the ability to change emacs theme
depending of the hour. There are two possibilities. One would be to sync
with the sun using the current location. There is an emacs package for
that. It's called theme-changer
which at the time of writing those lines is asking for a new maintainer.
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:
- early morning: deep yellow (gruvbox-light),
- morning: light yellow (solarized-light),
- day: grey/blueish during the day (nord-light),
- evening: deep yellow again (gruvbox-light)
- night: dark theme (oceanic-next)
- sleep time: neon-like (laserwave)
And also, I wanted that to follow my working hours and not really the
sun. I might change my mind and use the code of theme-changer to follow
the curve of the sun. But for now, just using straight hours should be
good enough. So here is my piece of code I added to my doom-emacs config.el
:
(defun y/auto-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 t))
;; run that function again next hour
(run-at-time (format "%02d:%02d" (+ hour 1) 0) nil 'y/auto-update-theme)))
(y/auto-update-theme)
I'm still playing with it. So there still might be a bug. Use at your
own risk. Happy hacking to all of you.