help-guix
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Emacs in server mode using a Shepherd user service


From: Maxim Cournoyer
Subject: Re: Emacs in server mode using a Shepherd user service
Date: Wed, 20 Nov 2019 06:57:57 +0900
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux)

Hello!

address@hidden writes:

> On 18.11.2019 00:10, Chris Marusich wrote:
>> Hi Maxim,
>>
>> Maxim Cournoyer <address@hidden> writes:
>>
>>> I typically start Emacs in server mode using a shepherd user service,
>>> so rarely restart Emacs.
>>
>> If it isn't too much to ask, could you share the configuration you use
>> to accomplish this?  I'd like to do something similar, and I suspect
>> it's probably one of those things that is "easy to do" if you already
>> know exactly what to do, and rather time-consuming to figure out
>> otherwise.  Perhaps we could make another Cook Book section about it?
>
> Seconding Chris' comment
>
> Brett Gilio

A Cook Book section would indeed be great!  I originally was enlightened
by Dave Thompson on how to go about it.

In my ~/.config/shepherd directory, I have two Scheme files:

init.scm
--8<---------------cut here---------------start------------->8---
;;; Shepherd User Services
(load "services.scm")

(register-services
 emacs
 gpg-agent
 jackd
 ibus-daemon
 workrave)

;; Send shepherd into the background.
(action 'shepherd 'daemonize)

;; Services to start when shepherd starts:
(for-each start '(emacs
                  gpg-agent
                  ibus-daemon
                  workrave))
--8<---------------cut here---------------end--------------->8---

services.scm
--8<---------------cut here---------------start------------->8---
(define emacs
  (make <service>
    #:provides '(emacs)
    #:requires '()
    #:start (make-system-constructor "emacs --daemon")
    #:stop (make-system-destructor "emacsclient --eval \"(kill-emacs)\"")))

(define ibus-daemon
  (make <service>
    #:provides '(ibus-daemon)
    #:requires '()
    #:start (make-system-constructor "ibus-daemon --xim --daemonize --replace")
    #:stop (make-system-destructor "pkill ibus-daemon")))

(define jackd
  (make <service>
    #:provides '(jackd)
    #:requires '()
    #:start (make-system-constructor "jackd -d alsa &")
    #:stop (make-system-destructor "pkill jackd")))

(define gpg-agent
  (let ((pinentry (string-append (getenv "HOME")
                                 "/.guix-profile/bin/pinentry")))
    (make <service>
      #:provides '(gpg-agent)
      #:requires '()
      #:start (make-system-constructor
               (string-append "gpg-agent --daemon "
                              "--pinentry-program " pinentry))
      #:stop (make-system-destructor "gpgconf --kill gpg-agent"))))

(define workrave
  (make <service>
    #:provides '(workrave)
    #:requires '()
    #:start (make-system-constructor "workrave &")
    #:stop (make-system-destructor "pkill workrave")))
--8<---------------cut here---------------end--------------->8---

I've included all the services I currently use in case they might be of
interest.

The last bit that is needed (other than having the required software
installed to your profile, including shepherd), is to launch shepherd
when your session starts:

For me, that is simply calling 'shepherd' in my ~/.xsession, just before
the call to my window manager (ratpoison).

I then start Emacs using 'emacsclient -c'.

HTH!

Maxim



reply via email to

[Prev in Thread] Current Thread [Next in Thread]