Add service for notifications for MPD

This commit is contained in:
Tom Willemse 2023-03-07 23:51:42 -08:00
parent 82ae1b59a6
commit 20f5597d39
3 changed files with 89 additions and 3 deletions

View file

@ -52,7 +52,8 @@
#:select (home-mpd-service-type #:select (home-mpd-service-type
home-mpd-configuration home-mpd-configuration
<home-mpd-audio-output> <home-mpd-audio-output>
home-mpc-update-service-type)) home-mpc-update-service-type
home-mpd-notify-service-type))
#:use-module ((oni home services picom) #:use-module ((oni home services picom)
#:select (home-picom-service-type #:select (home-picom-service-type
home-picom-configuration)) home-picom-configuration))
@ -224,4 +225,5 @@
#:name "Visualizer" #:name "Visualizer"
#:path "/tmp/mpd.fifo" #:path "/tmp/mpd.fifo"
#:format "44100:16:2"))))) #:format "44100:16:2")))))
(service home-mpc-update-service-type)))) (service home-mpc-update-service-type)
(service home-mpd-notify-service-type))))

View file

@ -9,13 +9,18 @@
#:use-module (srfi srfi-1) #:use-module (srfi srfi-1)
#:use-module (oop goops) #:use-module (oop goops)
#:use-module (ice-9 string-fun) #:use-module (ice-9 string-fun)
#:use-module ((oni packages mpd-notify)
#:select (mpd-notify))
#:export (home-mpd-service-type #:export (home-mpd-service-type
home-mpd-configuration home-mpd-configuration
<home-mpd-audio-output> <home-mpd-audio-output>
home-mpc-update-service-type 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) (define (serialize-boolean field value)
"") "")
@ -161,3 +166,40 @@
(compose identity) (compose identity)
(default-value (home-mpc-update-configuration)) (default-value (home-mpc-update-configuration))
(description "Install and configure mpc update."))) (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.")))

View file

@ -0,0 +1,42 @@
(define-module (oni packages mpd-notify)
#:use-module ((guix licenses) #:prefix license:)
#:use-module (gnu packages base)
#:use-module (gnu packages shells)
#:use-module (gnu packages mpd)
#:use-module (gnu packages gnome)
#:use-module (guix build-system gnu)
#:use-module (guix git-download)
#:use-module (guix packages))
(define-public mpd-notify
(let ((commit "66547ca1139d28855917382c868ddf2723d5afd4")
(revision "0"))
(package
(name "mpd-notify")
(version (git-version "0.0.0" revision commit))
(source
(origin
(uri (git-reference
(url "git://ryuslash.org/util/tom/mpd-notify")
(commit commit)))
(method git-fetch)
(sha256
(base32 "0r1ba6p1bsfz2k6zh5c6aivj9b71g7a00bgm8m22x6bdbsbm5gvb"))
(file-name (git-file-name name version))))
(propagated-inputs
(list mpd-mpc zsh libnotify))
(build-system gnu-build-system)
(arguments
`(#:tests? #f
#:phases
(modify-phases %standard-phases
(delete 'configure)
(delete 'build)
(replace 'install
(lambda* (#:key outputs #:allow-other-keys)
(let ((bin (string-append (assoc-ref outputs "out") "/bin")))
(install-file "mpd-notify" bin)))))))
(home-page "https://ryuslash.org/")
(synopsis "A simple script that notifies you of MPD player state changes.")
(description "Uses `mpc idleloop' to listen to player state changes and sends notifications.")
(license license:gpl3+))))