Automatically reload stumpwm if any changes are made to its config

This commit is contained in:
Tom Willemse 2023-03-17 00:33:19 -07:00
parent 300c22cb56
commit 201ea4662b

View file

@ -3,14 +3,18 @@
#:select (serialize-package #:select (serialize-package
define-configuration)) define-configuration))
#:use-module ((gnu packages wm) #:use-module ((gnu packages wm)
#:select (stumpwm)) #:select (stumpwm
stumpish))
#:use-module ((gnu home services) #:use-module ((gnu home services)
#:select (service-type #:select (service-type
service-extension service-extension
home-profile-service-type home-profile-service-type
home-xdg-configuration-files-service-type)) home-xdg-configuration-files-service-type
home-run-on-change-service-type))
#:use-module ((guix gexp) #:use-module ((guix gexp)
#:select (local-file)) #:select (local-file
gexp
file-append))
#:use-module ((guix packages) #:use-module ((guix packages)
#:select (package?)) #:select (package?))
@ -20,14 +24,22 @@
(define-configuration home-stumpwm-configuration (define-configuration home-stumpwm-configuration
(package (package
(package stumpwm) (package stumpwm)
"Package to use for setting Stumpwm")) "Package to use for setting Stumpwm")
(stumpish-package
(package stumpish)
"Package to use for setting Stumpish"))
(define (add-stumpwm-packages config) (define (add-stumpwm-packages config)
(list (home-stumpwm-configuration-package config))) (list (home-stumpwm-configuration-package config)
(home-stumpwm-configuration-stumpish-package config)))
(define (home-stumpwm-config-files config) (define (home-stumpwm-config-files config)
`(("stumpwm/config" ,(local-file "stumpwm/config")))) `(("stumpwm/config" ,(local-file "stumpwm/config"))))
(define (reload-stumpwm-config-gexp _)
`(("files/.config/stumpwm/config"
,#~(system* #$(file-append stumpish "/bin/stumpish") "reload"))))
(define home-stumpwm-service-type (define home-stumpwm-service-type
(service-type (service-type
(name 'home-stumpwm) (name 'home-stumpwm)
@ -37,7 +49,10 @@
add-stumpwm-packages) add-stumpwm-packages)
(service-extension (service-extension
home-xdg-configuration-files-service-type home-xdg-configuration-files-service-type
home-stumpwm-config-files))) home-stumpwm-config-files)
(service-extension
home-run-on-change-service-type
reload-stumpwm-config-gexp)))
(compose identity) (compose identity)
(default-value (home-stumpwm-configuration)) (default-value (home-stumpwm-configuration))
(description "Install and configure stumpwm."))) (description "Install and configure stumpwm.")))