(define-module (oni home services xdisorg) #:use-module ((gnu home services) #:select (service-type service-extension home-profile-service-type home-xdg-configuration-files-service-type home-run-on-change-service-type)) #:use-module ((gnu home services shepherd) #:select (home-shepherd-service-type shepherd-service)) #:use-module ((gnu packages admin) #:select (shepherd)) #:use-module ((gnu packages xdisorg) #:select (xss-lock sxhkd)) #:use-module ((gnu services configuration) #:select (serialize-package define-configuration text-config? serialize-text-config)) #:use-module ((guix gexp) #:select (gexp file-append mixed-text-file)) #:use-module ((guix packages) #:select (package?)) #:export (home-xss-lock-configuration home-xss-lock-service-type home-sxhkd-configuration home-sxhkd-service-type)) (define-configuration home-xss-lock-configuration (package (package xss-lock) "Package to use for setting xss-lock")) (define (add-xss-lock-packages config) (list (home-xss-lock-configuration-package config))) (define (home-xss-lock-shepherd-service config) (list (shepherd-service (documentation "Start xss-lock") (provision '(xss-lock)) (auto-start? #t) (start #~(make-forkexec-constructor (list #$(file-append (home-xss-lock-configuration-package config) "/bin/xss-lock") "i3lock" "--" "--color" "222224") #:log-file (format #f "~a/.local/var/log/xss-lock.log" (getenv "HOME")))) (stop #~(make-kill-destructor))))) (define home-xss-lock-service-type (service-type (name 'home-xss-lock) (extensions (list (service-extension home-profile-service-type add-xss-lock-packages) (service-extension home-shepherd-service-type home-xss-lock-shepherd-service))) (compose identity) (default-value (home-xss-lock-configuration)) (description "Install and configure xss-lock."))) (define-configuration home-sxhkd-configuration (package (package sxhkd) "Package to use for setting sxhkd") (configurations (text-config '()) "Extra configuration.")) (define-configuration home-sxhkd-extension (configurations (text-config '()) "Extra configuration.")) (define (add-sxhkd-packages config) (list (home-sxhkd-configuration-package config))) (define (home-sxhkd-config-files config) `(("sxhkd/sxhkdrc" ,(mixed-text-file "sxhkdrc" (serialize-text-config config (home-sxhkd-configuration-configurations config)))))) (define (home-sxhkd-extensions original-config extension-configs) (home-sxhkd-configuration (inherit original-config) (configurations (apply append (home-sxhkd-configuration-configurations original-config) (map home-sxhkd-extension-configurations extension-configs))))) (define (home-sxhkd-shepherd-service config) (list (shepherd-service (documentation "Start sxhkd") (provision '(sxhkd)) (auto-start? #t) (start #~(make-forkexec-constructor (list #$(file-append (home-sxhkd-configuration-package config) "/bin/sxhkd")) #:log-file (format #f "~a/.local/var/log/sxhkd.log" (getenv "HOME")))) (stop #~(make-kill-destructor))))) (define (reload-sxhkd-config-gexp _) `(("files/.config/sxhkd/sxhkdrc" ,#~(system* #$(file-append shepherd "/bin/herd") "restart" "sxhkd")))) (define home-sxhkd-service-type (service-type (name 'home-sxhkd) (extensions (list (service-extension home-profile-service-type add-sxhkd-packages) (service-extension home-shepherd-service-type home-sxhkd-shepherd-service) (service-extension home-xdg-configuration-files-service-type home-sxhkd-config-files) (service-extension home-run-on-change-service-type reload-sxhkd-config-gexp))) (compose identity) (extend home-sxhkd-extensions) (default-value (home-sxhkd-configuration)) (description "Install and configure sxhkd.")))