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."))) diff --git a/oni/packages/mpd-notify.scm b/oni/packages/mpd-notify.scm new file mode 100644 index 0000000..cc6e23a --- /dev/null +++ b/oni/packages/mpd-notify.scm @@ -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+))))