From mboxrd@z Thu Jan 1 00:00:00 1970 From: brettg@posteo.net Subject: Re: Emacs in server mode using a Shepherd user service Date: Tue, 19 Nov 2019 22:58:59 +0100 Message-ID: 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> <87v9rfv89m.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Return-path: Received: from eggs.gnu.org ([2001:470:142:3::10]:35313) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iXBWd-0001GT-JR for help-guix@gnu.org; Tue, 19 Nov 2019 16:59:09 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iXBWc-0004wk-8p for help-guix@gnu.org; Tue, 19 Nov 2019 16:59:07 -0500 Received: from mout01.posteo.de ([185.67.36.65]:51635) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iXBWb-0004w5-L0 for help-guix@gnu.org; Tue, 19 Nov 2019 16:59:06 -0500 Received: from submission (posteo.de [89.146.220.130]) by mout01.posteo.de (Postfix) with ESMTPS id E3031160061 for ; Tue, 19 Nov 2019 22:59:03 +0100 (CET) In-Reply-To: <87v9rfv89m.fsf@gmail.com> 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: Maxim Cournoyer Cc: myglc2@gmail.com, Alex Kost , help-guix@gnu.org, Help-Guix On 19.11.2019 22:57, Maxim Cournoyer wrote: > 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 Perfect, thank you Maxim!