From 061cfd930c691d32d8fd68540055828a23da7c72 Mon Sep 17 00:00:00 2001 From: Tom Willemse Date: Mon, 7 Nov 2022 21:46:07 -0800 Subject: [PATCH] =?UTF-8?q?Add=20service=20that=20runs=20=E2=80=98mpc=20up?= =?UTF-8?q?date=E2=80=99=20on=20start-up?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- oni/home/config/rincewind.scm | 3 ++- oni/home/services/mpd.scm | 41 ++++++++++++++++++++++++++++++++++- 2 files changed, 42 insertions(+), 2 deletions(-) diff --git a/oni/home/config/rincewind.scm b/oni/home/config/rincewind.scm index 7b58931..4e4cacc 100644 --- a/oni/home/config/rincewind.scm +++ b/oni/home/config/rincewind.scm @@ -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)))) diff --git a/oni/home/services/mpd.scm b/oni/home/services/mpd.scm index 6719754..c64fef2 100644 --- a/oni/home/services/mpd.scm +++ b/oni/home/services/mpd.scm @@ -12,7 +12,10 @@ #:export (home-mpd-service-type home-mpd-configuration - )) + + + 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.")))