From 6a5782e209d0223c27264a3c12778f873f514cea Mon Sep 17 00:00:00 2001 From: David Thompson Date: Wed, 3 Jun 2015 11:30:43 -0400 Subject: dmd: Fix emacs and gpg-agent services so they are stoppable. --- dotfiles/.dmd.d/init.scm | 25 ++++++++++++++++++------- 1 file 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 #:provides (list (string->symbol program)) @@ -22,9 +33,8 @@ (make #: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 #:provides '(xmodmap) @@ -35,11 +45,12 @@ (make #: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 #:provides '(offlineimap) -- cgit v1.2.3