summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Thompson <dthompson@vistahigherlearning.com>2015-06-03 11:30:43 -0400
committerDavid Thompson <dthompson@vistahigherlearning.com>2015-06-03 11:30:43 -0400
commit6a5782e209d0223c27264a3c12778f873f514cea (patch)
tree5cfe4f8520a4e180b36700863960a7d068b4fa52
parentf6b7b3d13d85b68d71b307e6a543a554d1a1e173 (diff)
dmd: Fix emacs and gpg-agent services so they are stoppable.
-rw-r--r--dotfiles/.dmd.d/init.scm25
1 files changed, 18 insertions, 7 deletions
diff --git a/dotfiles/.dmd.d/init.scm b/dotfiles/.dmd.d/init.scm
index 99edf73..4effd13 100644
--- a/dotfiles/.dmd.d/init.scm
+++ b/dotfiles/.dmd.d/init.scm
@@ -8,6 +8,17 @@
(0 (begin body ...))
(pid pid)))
+(define (run-command command)
+ (zero? (status:exit-val (apply system* command))))
+
+(define (make-system-constructor command)
+ (lambda _
+ (run-command command)))
+
+(define (make-system-destructor command)
+ (lambda _
+ (not (run-command command))))
+
(define (simple-service program)
(make <service>
#:provides (list (string->symbol program))
@@ -22,9 +33,8 @@
(make <service>
#:provides '(emacs)
#:requires '()
- ;; FIXME: Stopping this service doesn't kill emacs because it was
- ;; daemonized.
- #:start (make-forkexec-constructor (list "emacs" "--daemon")))
+ #:start (make-system-constructor '("emacs" "--daemon"))
+ #:stop (make-system-destructor '("emacsclient" "--eval" "(kill-emacs)")))
;; Customize X key bindings.
(make <service>
#:provides '(xmodmap)
@@ -35,11 +45,12 @@
(make <service>
#:provides '(gpg-agent)
#:requires '()
- #:start (make-forkexec-constructor
- (list "gpg-agent"
- "--enable-ssh-support"
+ #:start (make-system-constructor
+ (list "gpg-agent" "--daemon" "--enable-ssh-support"
"--pinentry-program"
- (string-append %home "/.guix-profile/bin/pinentry-gtk-2"))))
+ (string-append %home "/.guix-profile/bin/pinentry-gtk-2")))
+ #:stop (make-system-destructor
+ '("gpg-connect-agent" "killagent" "/bye")))
;; Mailbox sync.
(make <service>
#:provides '(offlineimap)