During the day, I like a light theme, but in the evening I prefer a dark theme. Off course it is possible to change my theme twice a day, but that gets old quickly, and be honest, who wouldn’t want to spend an hour on elisp to save a couple of minutes of drudgery?
Emacs knows when it gets dark, or for the early risers, when it gets light (see: Sunrise/Sunset – GNU Emacs Manual), so from that it is possible to infer when to switch themes.
As it happens, Joshua Griffith figured that out as well and put theme-changer on github:
Description: “Given a location and day/night color themes, this file provides a `change-theme` function that selects the appropriate theme based on whether it is day or night. It will continue to change themes at sunrise and sunset.”
I like to install my stuff through el-get, but there is no recipe yet, so I createda recipe and installed the package:
(:name theme-changer :website "https://github.com/hadronzoo/theme-changer" :description "Minor mode for editing WordPress files with Emacs." :type github :pkgname "hadronzoo/theme-changer" )
Setting up theme changer is very simple, it needs a location, so it knows when the switch themes, and two themes, one for the evening and one for the day.
First, configure your location:
(setq calendar-location-name "The Hague, Netherlands") (setq calendar-latitude 52.0799) (setq calendar-longitude 4.3111)
Next we require theme-changer and set the themes we want to use (make sure they are installed already).
(require 'theme-changer) (change-theme 'solarized-light 'solarized-dark)
And now all that’s left is to wait until sundown…
After using it for a while
How does it actually work? So far not too bad. Themes automatically switch, but if my laptop is closed while Emacs is running switching does not work, and switcher gets confused. So far I play around with color-themes a bit too much, and switching is not too stable. The best solution is restarting Emacs, which takes only second or two, so that’s what I do.
Overal: nice package, will keep.