From 7cd78468a214f262403c369f1b7a7aa8e8c73a8e Mon Sep 17 00:00:00 2001 From: Ian Eure Date: Sun, 8 Sep 2024 16:10:20 -0700 Subject: [PATCH] gnu: Add home-jellyfin-mpv-shim-service-type. * gnu/home/services/media.scm (home-jellyfin-mpv-shim-service-type): New variable. * doc/guix.texi (Jellyfin Services): New section. * doc/guix.texi (Kodi Services): Add subheading. Change-Id: I037ab0602214fdaa1b032be51ff98ecf6b7ee16c --- doc/guix.texi | 31 +++++++++++++++++++++++++ gnu/home/services/media.scm | 46 ++++++++++++++++++++++++++++++++++++- 2 files changed, 76 insertions(+), 1 deletion(-) diff --git a/doc/guix.texi b/doc/guix.texi index 41ddce9792..96b7bcd9eb 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -54176,6 +54176,7 @@ an example of a service and its configuration that you could add to the @subsection Media Home Services @cindex kodi + The @uref{https://kodi.tv, Kodi media center} can be run as a daemon on a media server. With the @code{(gnu home services kodi)} service, you can configure Kodi to run upon login. @@ -55099,6 +55100,36 @@ mouse bindings. @end table @end deftp +@cindex jellyfin + +The @code{home-jellyfin-mpv-shim-service-type} in the @code{(gnu home +services media)} module runs a cast client for the +@uref{https://jellyfin.org/, Jellyfin} media system. + +To enable, add this to your home services: + +@lisp +(service home-jellyfin-mpv-shim-service-type) +@end lisp + +The service starts only if @code{jellyfin-mpv-shim} has been configured +with a remote server and credentials. This must be done manually, by +launching @code{jellyfin-mpv-shim}. After configuring the server, the +service will start automatically when you log in. + +@defvar home-jellyfin-mpv-shim-service-type +Type of the service which launches Jellyfin MPV Shim. +@end defvar + +@deftp {Data Type} home-jellyfin-mpv-shim-configuration +Available @code{home-jellyfin-mpv-shim-configuration} fields are: + +@table @asis +@item @code{package} (default: @code{jellyfin-mpv-shim}) (type: package) +The Jellyfin MPV Shim package to use. +@end table +@end deftp + @node Networking Home Services @subsection Networking Home Services diff --git a/gnu/home/services/media.scm b/gnu/home/services/media.scm index c6454dfe15..08af16690c 100644 --- a/gnu/home/services/media.scm +++ b/gnu/home/services/media.scm @@ -1,5 +1,6 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2023 Janneke Nieuwenhuizen +;;; Copyright © 2024, 2025 Ian Eure ;;; ;;; This file is part of GNU Guix. ;;; @@ -19,14 +20,20 @@ (define-module (gnu home services media) #:use-module (srfi srfi-26) #:use-module (gnu home services) + #:use-module (gnu home services desktop) #:use-module (gnu home services shepherd) #:use-module (gnu packages kodi) + #:use-module (gnu packages video) #:use-module (gnu services configuration) #:use-module (gnu services shepherd) + #:use-module (guix packages) #:use-module (guix records) #:use-module (guix gexp) #:export (home-kodi-configuration - home-kodi-service-type)) + home-kodi-service-type + + home-jellyfin-mpv-shim-configuration + home-jellyfin-mpv-shim-service-type)) ;;; @@ -66,3 +73,40 @@ (description "Install and configure the Kodi media center so that it runs as a Shepherd service."))) + +(define-configuration home-jellyfin-mpv-shim-configuration + (package + (file-like jellyfin-mpv-shim) + "The Jellyfin MPV Shim package to use")) + +(define (jellyfin-mpv-shim-shepherd-service config) + (list (shepherd-service + (documentation "Jellyfin MPV Shim.") + (provision '(jellyfin-mpv-shim jellyfin-client)) + + ;; Depend on 'x11-display', which sets 'DISPLAY' if an X11 server is + ;; available, and fails to start otherwise. + (requirement '(x11-display)) + + (modules '((srfi srfi-1) + (srfi srfi-26) + (srfi srfi-98))) + (start + #~(make-forkexec-constructor + (list + #$(file-append + (home-jellyfin-mpv-shim-configuration-package config) + "/bin/jellyfin-mpv-shim")))) + (stop #~(make-kill-destructor))))) + +(define-public home-jellyfin-mpv-shim-service-type + (service-type + (name 'home-jellyfin-mpv-shim) + (extensions (list (service-extension home-shepherd-service-type + jellyfin-mpv-shim-shepherd-service) + ;; Ensure 'home-x11-service-type' is instantiated so we + ;; can depend on the Shepherd 'x11-display' service. + (service-extension home-x11-service-type + (const #t)))) + (default-value (home-jellyfin-mpv-shim-configuration)) + (description "Run Jellyfin MPV Shim.")))