summaryrefslogtreecommitdiff
path: root/dotfiles/.dmd.d
diff options
context:
space:
mode:
authorDavid Thompson <dthompson2@worcester.edu>2015-05-19 09:02:17 -0400
committerDavid Thompson <dthompson2@worcester.edu>2015-05-19 09:02:17 -0400
commit56236c0e1aed4166fac8bd5908f28ddc5f928c96 (patch)
tree1580707df3639a61e10b1d3bfb6c7e57e560c446 /dotfiles/.dmd.d
parent1e579064aed9f32061e5edbe1c693cab21f0ce75 (diff)
Update dotfiles with new Guile-based installer.
Diffstat (limited to 'dotfiles/.dmd.d')
-rw-r--r--dotfiles/.dmd.d/init.scm38
1 files changed, 38 insertions, 0 deletions
diff --git a/dotfiles/.dmd.d/init.scm b/dotfiles/.dmd.d/init.scm
new file mode 100644
index 0000000..420c7cf
--- /dev/null
+++ b/dotfiles/.dmd.d/init.scm
@@ -0,0 +1,38 @@
+(use-modules (ice-9 match))
+
+(define-syntax-rule (forever body ...)
+ (while #t body ...))
+
+(define-syntax-rule (with-fork body ...)
+ (match (primitive-fork)
+ (0 (begin body ...))
+ (pid pid)))
+
+(define (simple-service program)
+ (make <service>
+ #:provides (list (string->symbol program))
+ #:requires '()
+ #:start (make-forkexec-constructor (list program))
+ #:stop (make-kill-destructor)))
+
+(register-services
+ (make <service>
+ #:provides '(offlineimap)
+ #:requires '()
+ #:start (lambda args
+ (with-fork
+ ;; OfflineIMAP's "autorefresh" mode consistently
+ ;; consumes all of the RAM on my machine, so let's just
+ ;; run it in a loop instead.
+ (forever
+ (system* "offlineimap")
+ (sleep 20))))
+ #:stop (make-kill-destructor))
+ (simple-service "mpd")
+ (simple-service "mpdscribble"))
+
+;; Send dmd into the background
+(action 'dmd 'daemonize)
+
+;; Services to start when dmd starts:
+(for-each start '(offlineimap mpd mpdscribble))