(define-module (ruther home services kanshi) #:use-module (guix gexp) #:use-module (gnu packages freedesktop) #:use-module (gnu services) #:use-module (gnu services configuration) #:use-module (gnu services shepherd) #:use-module (srfi srfi-26) #:use-module (srfi srfi-1) #:use-module (gnu home services) #:use-module (gnu home services shepherd) #:use-module (ruther home services wayland) #:export (home-kanshi-configuration home-swayidle-configuration)) (define-public (serialize-kanshi-configuration config) (apply mixed-text-file "config" ((@@ (rde home services wm) serialize-sway-config) config))) (define-public (serialize-swayidle-configuration config) (apply mixed-text-file "config" ((@@ (rde home services wm) serialize-sway-config) config))) (define sway-config? (@ (rde home services wm) sway-config?)) (define-configuration/no-serialization home-kanshi-configuration (kanshi (file-like kanshi) "Kanshi package to use.") (config sway-config "Configuration of the kanshi program itself. Goes into .config/kanshi/config. See `man 5 kanshi`")) (define (home-kanshi-shepherd-services config) (list (shepherd-service (documentation "Run the kanshi daemon for managing outputs.") (provision '(kanshi)) (requirement '(wayland-display)) (modules %display-environ-modules) (start #~(lambda _ (fork+exec-command (list #$(file-append (home-kanshi-configuration-kanshi config) "/bin/kanshi") "-c" #$(serialize-kanshi-configuration (home-kanshi-configuration-config config))) #:environment-variables #$%wayland-display-environ))) (stop #~(make-kill-destructor))))) (define-public home-kanshi-service-type (service-type (name 'home-kanshi) (description "A service for configuring and running kanshi through Shepherd") (extensions (list (service-extension home-shepherd-service-type home-kanshi-shepherd-services) (service-extension home-wayland-display-service-type (const #f)))))) (define-configuration/no-serialization home-swayidle-configuration (swayidle (file-like swayidle) "Swayidle package to use.") (config sway-config "Configuration of the swayidle program itself. Goes into .config/swayidle/config. See `man 5 swayidle`")) (define (home-swayidle-shepherd-services config) (list (shepherd-service (documentation "Run the swayidle daemon for managing commands executed when idle.") (provision '(swayidle)) (requirement '(wayland-display)) (modules %display-environ-modules) (start #~(lambda _ (fork+exec-command (list #$(file-append (home-swayidle-configuration-swayidle config) "/bin/swayidle") "-wC" #$(serialize-swayidle-configuration (home-swayidle-configuration-config config))) #:environment-variables #$%wayland-display-environ))) (stop #~(make-kill-destructor))))) (define-public home-swayidle-service-type (service-type (name 'home-swayidle) (description "A service for configuring and running swayidle through Shepherd") (extensions (list (service-extension home-shepherd-service-type home-swayidle-shepherd-services) (service-extension home-wayland-display-service-type (const #f))))))