From 20f5597d394ae7dd1764e184d084257652a7ca10 Mon Sep 17 00:00:00 2001 From: Tom Willemse Date: Tue, 7 Mar 2023 23:51:42 -0800 Subject: Add service for notifications for MPD --- oni/home/config/rincewind.scm | 6 ++++-- oni/home/services/mpd.scm | 44 ++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 47 insertions(+), 3 deletions(-) (limited to 'oni/home') diff --git a/oni/home/config/rincewind.scm b/oni/home/config/rincewind.scm index 7b397a5..8d82bef 100644 --- a/oni/home/config/rincewind.scm +++ b/oni/home/config/rincewind.scm @@ -52,7 +52,8 @@ #:select (home-mpd-service-type home-mpd-configuration - home-mpc-update-service-type)) + home-mpc-update-service-type + home-mpd-notify-service-type)) #:use-module ((oni home services picom) #:select (home-picom-service-type home-picom-configuration)) @@ -224,4 +225,5 @@ #:name "Visualizer" #:path "/tmp/mpd.fifo" #:format "44100:16:2"))))) - (service home-mpc-update-service-type)))) + (service home-mpc-update-service-type) + (service home-mpd-notify-service-type)))) diff --git a/oni/home/services/mpd.scm b/oni/home/services/mpd.scm index c64fef2..992a6c2 100644 --- a/oni/home/services/mpd.scm +++ b/oni/home/services/mpd.scm @@ -9,13 +9,18 @@ #:use-module (srfi srfi-1) #:use-module (oop goops) #:use-module (ice-9 string-fun) + #:use-module ((oni packages mpd-notify) + #:select (mpd-notify)) #:export (home-mpd-service-type home-mpd-configuration home-mpc-update-service-type - home-mpc-update-configuration)) + home-mpc-update-configuration + + home-mpd-notify-service-type + home-mpd-notify-configuration)) (define (serialize-boolean field value) "") @@ -161,3 +166,40 @@ (compose identity) (default-value (home-mpc-update-configuration)) (description "Install and configure mpc update."))) + +(define-configuration home-mpd-notify-configuration + (package + (package mpd-notify) + "Package to use for setting MPD notify") + (auto-start? + (boolean #t) + "Should mpd notify be started automatically?")) + +(define (add-mpd-notify-packages config) + (list (home-mpd-notify-configuration-package config))) + +(define (home-mpd-notify-shepherd-service config) + (list + (shepherd-service + (documentation "Show notifications for MPD player state changes") + (provision '(mpd-notify)) + (auto-start? (home-mpd-notify-configuration-auto-start? config)) + (start + #~(make-forkexec-constructor + (list #$(file-append (home-mpd-notify-configuration-package config) "/bin/mpd-notify")) + #:log-file (format #f "~a/.local/var/log/mpd-notify.log" (getenv "HOME")))) + (stop #~(make-kill-destructor))))) + +(define home-mpd-notify-service-type + (service-type + (name 'home-mpd-notify) + (extensions + (list (service-extension + home-profile-service-type + add-mpd-notify-packages) + (service-extension + home-shepherd-service-type + home-mpd-notify-shepherd-service))) + (compose identity) + (default-value (home-mpd-notify-configuration)) + (description "Install and configure mpd notifications."))) -- cgit v1.2.3-54-g00ecf