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
define-configuration))
#:use-module ((gnu packages wm)
#:select (stumpwm))
#:select (stumpwm
stumpish))
#:use-module ((gnu home services)
#:select (service-type
service-extension
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)
#:select (local-file))
#:select (local-file
gexp
file-append))
#:use-module ((guix packages)
#:select (package?))
@ -20,14 +24,22 @@
(define-configuration home-stumpwm-configuration
(package
(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)
(list (home-stumpwm-configuration-package config)))
(list (home-stumpwm-configuration-package config)
(home-stumpwm-configuration-stumpish-package config)))
(define (home-stumpwm-config-files 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
(service-type
(name 'home-stumpwm)
@ -37,7 +49,10 @@
add-stumpwm-packages)
(service-extension
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)
(default-value (home-stumpwm-configuration))
(description "Install and configure stumpwm.")))