summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/guix.texi23
-rw-r--r--gnu/services/desktop.scm86
2 files changed, 109 insertions, 0 deletions
diff --git a/doc/guix.texi b/doc/guix.texi
index 7f587d73a9a..d3abbf29351 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -27888,6 +27888,29 @@ Package object for GVfs.
27888@end table 27888@end table
27889@end deftp 27889@end deftp
27890 27890
27891@defvar kanata-service-type
27892This is the type of the service that runs
27893@uref{https://github.com/jtroo/kanata, Kanata}, a keyboard layout
27894re-mapper. Its value is a @code{kanata-configuration} object. This
27895service allows spawning @command{kanata} configurations to manage
27896keyboards.
27897@end defvar
27898
27899@deftp {Data Type} kanata-configuration
27900Configuration record for the Kanata service.
27901
27902@table @asis
27903@item @code{kanata} (default: @code{kanata}) (type: package)
27904The Kanata package to use.
27905
27906@item @code{keymaps} (default: @code{()}) (type: list-of-file-likes)
27907List of @command{kanata} configuration files (file-like objects). See
27908@uref{https://jtroo.github.io/config.html#linux-only-linux-dev, Kanata's
27909device specification documentation}.
27910
27911@end table
27912@end deftp
27913
27891@defvar kmonad-service-type 27914@defvar kmonad-service-type
27892This is the type of the service that runs 27915This is the type of the service that runs
27893@uref{https://github.com/kmonad/kmonad, KMonad}. Its value is a 27916@uref{https://github.com/kmonad/kmonad, KMonad}. Its value is a
diff --git a/gnu/services/desktop.scm b/gnu/services/desktop.scm
index d4a8878bfd3..d0f56cc434c 100644
--- a/gnu/services/desktop.scm
+++ b/gnu/services/desktop.scm
@@ -81,6 +81,7 @@
81 #:use-module (gnu packages nfs) 81 #:use-module (gnu packages nfs)
82 #:use-module (gnu packages enlightenment) 82 #:use-module (gnu packages enlightenment)
83 #:use-module (gnu packages haskell-apps) 83 #:use-module (gnu packages haskell-apps)
84 #:use-module (gnu packages rust-apps)
84 #:use-module (guix deprecation) 85 #:use-module (guix deprecation)
85 #:use-module (guix i18n) 86 #:use-module (guix i18n)
86 #:use-module (guix records) 87 #:use-module (guix records)
@@ -130,6 +131,12 @@
130 kmonad-configuration? 131 kmonad-configuration?
131 kmonad-service-type 132 kmonad-service-type
132 133
134 kanata-service-type
135 kanata-configuration
136 kanata-configuration?
137 kanata-configuration-kanata
138 kanata-configuration-keymaps
139
133 geoclue-application 140 geoclue-application
134 geoclue-configuration 141 geoclue-configuration
135 geoclue-configuration? 142 geoclue-configuration?
@@ -1110,6 +1117,85 @@ and extending the functionalities of different keyboards.")))
1110 1117
1111 1118
1112;;; 1119;;;
1120;;; Kanata.
1121;;;
1122
1123(define-configuration/no-serialization kanata-configuration
1124 (kanata
1125 (package kanata)
1126 "The @code{kanata} package to use.")
1127 (keymaps
1128 (list-of-file-likes '())
1129 "List of @command{kanata} configuration files (file-like objects). See
1130@uref{https://jtroo.github.io/config.html#linux-only-linux-dev, Kanata's
1131device specification documentation}."))
1132
1133(define %kanata-group
1134 (user-group
1135 (name "kanata")
1136 (system? #t)))
1137
1138(define %kanata-user
1139 (user-account
1140 (name "kanata")
1141 (group "kanata")
1142 (supplementary-groups '("input" "uinput"))
1143 (system? #t)
1144 (comment "Kanata daemon user")
1145 (home-directory "/var/empty")
1146 (create-home-directory? #f)
1147 (shell (file-append shadow "/sbin/nologin"))))
1148
1149(define %kanata-accounts
1150 (list %uinput-group %kanata-group %kanata-user))
1151
1152;; OPTIONS+="static_node=uinput" triggers kmod to load the uinput module on
1153;; boot.
1154(define %kanata-udev-rule
1155 (udev-rule
1156 "99-kanata.rules"
1157 "KERNEL==\"uinput\", MODE=\"0660\", GROUP=\"uinput\", OPTIONS+=\"static_node=uinput\"\n"))
1158
1159(define (kanata-shepherd-services config)
1160 "Return a shepherd service for each @command{kanata} configuration."
1161 (let* ((kanata (file-append (kanata-configuration-kanata config)
1162 "/bin/kanata"))
1163 (keymaps (kanata-configuration-keymaps config)))
1164 (map (lambda (index keymap)
1165 (let ((name (string-append "kanata-" (number->string index))))
1166 (shepherd-service
1167 (provision (list (string->symbol name)))
1168 (requirement '(user-processes udev))
1169 (documentation (string-append "Run kanata process "
1170 (number->string index) "."))
1171 (start #~(make-forkexec-constructor
1172 ;; '--no-wait' prevents pausing on exit so
1173 ;; Shepherd can reliably restart the daemon.
1174 (list #$kanata "-c" #$keymap "--no-wait")
1175 #:user "kanata"
1176 #:group "kanata"
1177 #:supplementary-groups '("input" "uinput")
1178 #:log-file #$(string-append "/var/log/" name ".log")))
1179 (stop #~(make-kill-destructor)))))
1180 (iota (length keymaps))
1181 keymaps)))
1182
1183(define kanata-service-type
1184 (service-type
1185 (name 'kanata)
1186 (extensions
1187 (list (service-extension account-service-type
1188 (const %kanata-accounts))
1189 (service-extension shepherd-root-service-type
1190 kanata-shepherd-services)
1191 (service-extension udev-service-type
1192 (const (list %kanata-udev-rule)))))
1193 (description
1194 "Run the @command{kanata} daemon, which allows customizing and extending
1195the functionalities of different keyboards.")))
1196
1197
1198;;;
1113;;; UDisks. 1199;;; UDisks.
1114;;; 1200;;;
1115 1201