2022-04-02 09:29:25 +02:00
|
|
|
(define-module (oni home services xmodmap)
|
|
|
|
#:use-module (gnu services configuration)
|
|
|
|
#:use-module (gnu packages xorg)
|
|
|
|
#:use-module (gnu home services)
|
2022-04-13 06:33:15 +02:00
|
|
|
#:use-module (gnu home services shepherd)
|
2022-04-02 09:29:25 +02:00
|
|
|
#:use-module (gnu home services utils)
|
|
|
|
#:use-module (guix packages)
|
|
|
|
#:use-module (guix gexp)
|
|
|
|
|
|
|
|
#:export (home-xmodmap-service-type
|
|
|
|
home-xmodmap-configuration))
|
|
|
|
|
|
|
|
(define-configuration/no-serialization home-xmodmap-configuration
|
|
|
|
(package
|
|
|
|
(package xmodmap)
|
|
|
|
"Package to use for setting Xmodmap")
|
2022-04-07 06:13:44 +02:00
|
|
|
(auto-start?
|
|
|
|
(boolean #t)
|
|
|
|
"Should xmodmap be started automatically")
|
2022-04-02 09:29:25 +02:00
|
|
|
(pointer
|
|
|
|
(list '())
|
|
|
|
"List of numbers indicating the order of numbers")
|
|
|
|
(extra
|
|
|
|
(text-config '())
|
|
|
|
"Any other configuration settings."))
|
|
|
|
|
|
|
|
(define (serialize-xmodmap-config config)
|
|
|
|
(let ((pointer (home-xmodmap-configuration-pointer config)))
|
|
|
|
(string-append
|
|
|
|
(if pointer
|
|
|
|
(string-append "pointer = " (string-join (map number->string pointer) " ") "\n\n")
|
|
|
|
"")
|
|
|
|
(string-join (home-xmodmap-configuration-extra config) "\n" 'suffix))))
|
|
|
|
|
2022-04-07 06:13:44 +02:00
|
|
|
(define (xmodmap-home-config-file config)
|
|
|
|
(mixed-text-file
|
|
|
|
"Xmodmap"
|
|
|
|
(serialize-xmodmap-config config)))
|
2022-04-02 09:29:25 +02:00
|
|
|
|
2022-04-05 09:59:59 +02:00
|
|
|
(define (add-xmodmap-packages config)
|
|
|
|
(list (home-xmodmap-configuration-package config)))
|
|
|
|
|
2022-04-13 06:33:15 +02:00
|
|
|
(define (home-xmodmap-shepherd-service config)
|
|
|
|
(list
|
|
|
|
(shepherd-service
|
|
|
|
(documentation "Start Xmodmap")
|
|
|
|
(provision '(xmodmap))
|
|
|
|
(auto-start? (home-xmodmap-configuration-auto-start? config))
|
|
|
|
(one-shot? #t)
|
|
|
|
(start
|
|
|
|
#~(make-forkexec-constructor
|
|
|
|
'(#$(file-append xmodmap "/bin/xmodmap")
|
|
|
|
#$(xmodmap-home-config-file config)))))))
|
2022-04-07 06:13:44 +02:00
|
|
|
|
2022-04-02 09:29:25 +02:00
|
|
|
(define home-xmodmap-service-type
|
|
|
|
(service-type
|
|
|
|
(name 'home-xmodmap)
|
|
|
|
(extensions
|
|
|
|
(list (service-extension
|
2022-04-05 09:59:59 +02:00
|
|
|
home-profile-service-type
|
2022-04-07 06:13:44 +02:00
|
|
|
add-xmodmap-packages)
|
|
|
|
(service-extension
|
2022-04-13 06:33:15 +02:00
|
|
|
home-shepherd-service-type
|
|
|
|
home-xmodmap-shepherd-service)))
|
2022-04-02 09:29:25 +02:00
|
|
|
(compose identity)
|
|
|
|
(default-value (home-xmodmap-configuration))
|
|
|
|
(description "Install and configure Xmodmap.")))
|