@@ -46042,6 +46042,8 @@ Media Home Services
@subsection Media Home Services
@cindex kodi
+@subsubheading Kodi Services
+
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.
@@ -46074,6 +46076,21 @@ Media Home Services
@end table
@end deftp
+@cindex jellyfin
+@subsubheading Jellyfin Services
+
+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 #f)
+@end lisp
+
+@defvar home-jellyfin-mpv-shim-service-type
+The type of the Jellyfin MPV Shim service.
+@end defvar
+
@node Networking Home Services
@subsection Networking Home Services
@@ -19,8 +19,10 @@
(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 records)
@@ -66,3 +68,36 @@ (define home-kodi-service-type
(description
"Install and configure the Kodi media center so that it runs as a Shepherd
service.")))
+
+(define (jellyfin-mpv-shim-shepherd-service _ignore)
+ (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)))
+ (start #~(lambda _
+ (fork+exec-command
+ (list #$(file-append jellyfin-mpv-shim "/bin/jellyfin-mpv-shim"))
+
+ ;; Inherit the 'DISPLAY' variable set by 'x11-display'.
+ #:environment-variables
+ (cons (string-append "DISPLAY=" (getenv "DISPLAY"))
+ (remove (cut string-prefix? "DISPLAY=" <>)
+ (default-environment-variables))))))
+ (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))))
+ (description "Run Jellyfin MPV Shim.")))