From mboxrd@z Thu Jan 1 00:00:00 1970 From: Maxim Cournoyer Subject: Re: Emacs in server mode using a Shepherd user service Date: Wed, 20 Nov 2019 06:57:57 +0900 Message-ID: <87v9rfv89m.fsf@gmail.com> References: <9c395fd0-9458-7894-af8b-9294d212c60b@fastmail.net> <87a7uyd7qy.fsf@gmail.com> <874ll51mq3.fsf@gmail.com> <87zi2t4jgh.fsf@gmail.com> <877ep4z44b.fsf@gmail.com> <87tv88ihzc.fsf@ambrevar.xyz> <878spgo7ex.fsf@gmail.com> <87o8yccwtq.fsf@ambrevar.xyz> <871rv1ed8v.fsf@gmail.com> <87mudpm5nt.fsf@ambrevar.xyz> <874kzscpgs.fsf@gmail.com> <87eeyvespq.fsf@ambrevar.xyz> <87zhhhbhzl.fsf@gmail.com> <877e4l5c9h.fsf@ambrevar.xyz> <87mudgb4v5.fsf@gmail.com> <87pnib76x1.fsf@ambrevar.xyz> <878sozaxox.fsf@gmail.com> <87a78uqeul.fsf_-_@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:470:142:3::10]:35133) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iXBVb-0000u4-Ki for help-guix@gnu.org; Tue, 19 Nov 2019 16:58:04 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iXBVa-0004VQ-GT for help-guix@gnu.org; Tue, 19 Nov 2019 16:58:03 -0500 In-Reply-To: (brettg@posteo.net's message of "Mon, 18 Nov 2019 21:55:44 +0100") List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-guix-bounces+gcggh-help-guix=m.gmane.org@gnu.org Sender: "Help-Guix" To: brettg@posteo.net Cc: myglc2@gmail.com, Alex Kost , help-guix@gnu.org, Help-Guix Hello! brettg@posteo.net writes: > On 18.11.2019 00:10, Chris Marusich wrote: >> Hi Maxim, >> >> Maxim Cournoyer 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 #:provides '(emacs) #:requires '() #:start (make-system-constructor "emacs --daemon") #:stop (make-system-destructor "emacsclient --eval \"(kill-emacs)\""))) (define ibus-daemon (make #:provides '(ibus-daemon) #:requires '() #:start (make-system-constructor "ibus-daemon --xim --daemonize --replace") #:stop (make-system-destructor "pkill ibus-daemon"))) (define jackd (make #: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 #: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 #: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