summaryrefslogtreecommitdiff
path: root/dotfiles/.dmd.d/init.scm
blob: 420c7cfb3f05014e7d1d48a6eb138c59bb5137ed (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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))