Subject: Re: bug#31769: mpd / pulse control issue

From: Leo Famulari <[email-masked]>
Date: Sun, 10 Jun 2018 23:33:53 -0400

On Sat, Jun 09, 2018 at 06:58:03AM -0500, Bradley Haggerty wrote:
> When I start my computer, mpd can play my music fine, but pavucontrol can't
> connect to pulse and show my volume controls. If I kill pulse and open
> pavucontrol, all my volume controls are visible, but then mpd can't play
> music.

As 宋文武 and Julien said, this should be fixed in our service but it might be
tricky to do without being able to listen to music ;)

In the meantime, If it suits your needs, you can run MPD with your
unprivileged user instead of at the system level.

Below is a file I use to start MPD as my own user on GuixSD, and it
seems to do the right thing regarding PulseAudio, although I use
pulsemixer instead of pavucontrol.

I originally copied the file from Dave Thompson... any mistakes are my
own :)

By the way, the file should be named '~/.config/shepherd/init.scm'.

------
;; To use this automatically, add something like the following line to
;; whatever gets sourced for a login shell:
;;
;; [[ -z $(pgrep -U $(id --user) shepherd) ]] && shepherd & > /dev/null
;;
;; Or, just invoke `shepherd`.

(use-modules (ice-9 match)
             (srfi srfi-1)
             (system repl server))

(define (touch-file file)
  (close-port (open-file file "a0b")))

(register-services

  (make <service>
    #:provides '(mpd)
    #:requires '() 
    #:start (lambda args
              (define (mpd-dir file)
                (string-append (getenv "HOME") "/.mpd/" file))
              (unless (file-exists? (mpd-dir "playlists"))
                (mkdir (mpd-dir "playlists")))
              (touch-file (mpd-dir "database"))
              (fork+exec-command
               (list "mpd" "--no-daemon")))
    #:stop (make-kill-destructor)))

(action 'shepherd 'daemonize)

(for-each start '(mpd))
------