Run At Sun Event daemon
Emacs Lisp
Switch branches/tags
Nothing to show
Pull request Compare This branch is even with m00natic:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

rase.el - Run At Sun Event daemon

This is an Emacs extension that allows user provided set of functions to run at some sun events - sunrise, midday (sun is at highest point for current coordinates), sunset and midnight (sun at lowest).

It’s inspired by some settings found in Juri Linkov’s .emacs.


The solar built-in package is used and the calendar-latitude and calendar-longitude variables must be set to appropriate location.

Usage example

;; currently in Sofia, Bulgaria
 '(calendar-latitude 42.7)
 '(calendar-longitude 23.3))

(require 'rase)

;; load without enabling some GNU/Emacs 24 built-in themes
(load-theme 'whiteboard t t)
(load-theme 'wombat t t)

;; create a two-argument function to be invoked at sun events
(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 'wombat)
	     (enable-theme 'whiteboard))
	    ((memq sun-event '(sunset midnight))
	     (disable-theme 'whiteboard)
	     (enable-theme 'wombat)))
    (cond ((eq sun-event 'sunrise)    ; after initialization deal only
	   (disable-theme 'wombat)    ; with sunrise and sunset
	   (enable-theme 'whiteboard))
	  ((eq sun-event 'sunset)
	   (disable-theme 'whiteboard)
	   (enable-theme 'wombat)))))

;; 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)

;; you can stop it like this