Add service that runs ‘mpc update’ on start-up

This commit is contained in:
Tom Willemse 2022-11-07 21:46:07 -08:00
parent 5f46121fc7
commit 061cfd930c
2 changed files with 42 additions and 2 deletions

View file

@ -128,4 +128,5 @@
#:type "fifo"
#:name "Visualizer"
#:path "/tmp/mpd.fifo"
#:format "44100:16:2"))))))))
#:format "44100:16:2")))))
(service home-mpc-update-service-type))))

View file

@ -12,7 +12,10 @@
#:export (home-mpd-service-type
home-mpd-configuration
<home-mpd-audio-output>))
<home-mpd-audio-output>
home-mpc-update-service-type
home-mpc-update-configuration))
(define (serialize-boolean field value)
"")
@ -122,3 +125,39 @@
(compose identity)
(default-value (home-mpd-configuration))
(description "Install and configure mpd.")))
(define-configuration home-mpc-update-configuration
(package
(package mpd-mpc)
"Package to use for setting MPC update")
(auto-start?
(boolean #t)
"Should mpc update be started automatically"))
(define (add-mpc-update-packages config)
(list (home-mpc-update-configuration-package config)))
(define (home-mpc-update-shepherd-service config)
(list
(shepherd-service
(documentation "Update MPD database")
(provision '(mpd-update))
(auto-start? (home-mpc-update-configuration-auto-start? config))
(one-shot? #t)
(start
#~(make-forkexec-constructor
'(#$(file-append mpd-mpc "/bin/mpc") "update"))))))
(define home-mpc-update-service-type
(service-type
(name 'home-mpc-update)
(extensions
(list (service-extension
home-profile-service-type
add-mpc-update-packages)
(service-extension
home-shepherd-service-type
home-mpc-update-shepherd-service)))
(compose identity)
(default-value (home-mpc-update-configuration))
(description "Install and configure mpc update.")))