From 53cc05214fbaa1ea30b170c0dac2e264bc1a0a59 Mon Sep 17 00:00:00 2001 From: Tom Willemse Date: Wed, 19 Jun 2024 23:02:35 -0700 Subject: Add mpdscrobble service --- oni/home/services/mpd.scm | 49 +++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 47 insertions(+), 2 deletions(-) (limited to 'oni/home/services') diff --git a/oni/home/services/mpd.scm b/oni/home/services/mpd.scm index c3c272c..0fcd411 100644 --- a/oni/home/services/mpd.scm +++ b/oni/home/services/mpd.scm @@ -10,7 +10,8 @@ #:use-module (oop goops) #:use-module (ice-9 string-fun) #:use-module ((oni packages mpd) - #:select (mpd-notify)) + #:select (mpd-notify + mpdscrobble)) #:export (home-mpd-service-type home-mpd-configuration @@ -20,7 +21,10 @@ home-mpc-update-configuration home-mpd-notify-service-type - home-mpd-notify-configuration)) + home-mpd-notify-configuration + + home-mpdscrobble-service-type + home-mpdscrobble-configuration)) (define (serialize-boolean field value) "") @@ -204,3 +208,44 @@ (compose identity) (default-value (home-mpd-notify-configuration)) (description "Install and configure mpd notifications."))) + +(define-configuration home-mpdscrobble-configuration + (package + (package mpdscrobble) + "Pakcage to use for setting mpdscrobble") + (auto-start? + (boolean #t) + "Should mpdscrobble be started automatically?")) + +(define (add-mpdscrobble-packages config) + (list (home-mpdscrobble-configuration-package config))) + +(define (home-mpdscrobble-shepherd-service config) + (list + (shepherd-service + (documentation "Scrobble songs to last.fm and/or maloja") + (provision '(mpdscrobble)) + (requirement '(mpd)) + (auto-start? (home-mpdscrobble-configuration-auto-start? config)) + (start + #~(make-forkexec-constructor + (list #$(file-append (home-mpdscrobble-configuration-package config) "/bin/mpdscrobble")) + #:log-file (format #f "~a/.local/var/log/mpdscrobble.log" (getenv "HOME")))) + (stop #~(make-kill-destructor)) + (respawn? #t) + (respawn-delay 1) + (respawn-limit 60)))) + +(define home-mpdscrobble-service-type + (service-type + (name 'home-mpdscrobble) + (extensions + (list (service-extension + home-profile-service-type + add-mpdscrobble-packages) + (service-extension + home-shepherd-service-type + home-mpdscrobble-shepherd-service))) + (compose identity) + (default-value (home-mpdscrobble-configuration)) + (description "Install and configure mpdscrobble."))) -- cgit v1.2.3-54-g00ecf