From 598757e038ab5dea3b59c9c248a2ad860c41fe62 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Tue, 19 Mar 2019 21:34:02 +0100 Subject: services: xorg: Add a 'keyboard-layout' field in . * gnu/services/xorg.scm ()[keyboard-layout]: New field. (xorg-configuration->file)[input-class-section]: New procedure. Use it. * doc/guix.texi (X Window): Document 'keyboard-layout' field. Co-authored-by: nee --- gnu/services/xorg.scm | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 'gnu') diff --git a/gnu/services/xorg.scm b/gnu/services/xorg.scm index a3a4d769d7..05465f3bdf 100644 --- a/gnu/services/xorg.scm +++ b/gnu/services/xorg.scm @@ -25,6 +25,7 @@ #:use-module (gnu services) #:use-module (gnu services shepherd) #:use-module (gnu system pam) + #:use-module (gnu system keyboard) #:use-module (gnu services dbus) #:use-module ((gnu packages base) #:select (canonical-package)) #:use-module (gnu packages guile) @@ -147,6 +148,8 @@ (default '())) (resolutions xorg-configuration-resolutions ;list of tuples (default '())) + (keyboard-layout xorg-configuration-keyboard-layout ;#f | + (default #f)) (extra-config xorg-configuration-extra-config ;list of strings (default '())) (server xorg-configuration-server ;package @@ -195,6 +198,31 @@ Section \"Screen\" EndSubSection EndSection")) + (define (input-class-section layout variant model options) + (string-append " +Section \"InputClass\" + Identifier \"evdev keyboard catchall\" + MatchIsKeyboard \"on\" + Option \"XkbLayout\" " (object->string layout) + (if variant + (string-append " Option \"XkbVariant\" \"" + variant "\"") + "") + (if model + (string-append " Option \"XkbModel\" \"" + model "\"") + "") + (match options + (() + "") + (_ + (string-append " Option \"XkbOptions\" \"" + (string-join options ",") "\""))) " + + MatchDevicePath \"/dev/input/event*\" + Driver \"evdev\" +EndSection\n")) + (define (expand modules) ;; Append to MODULES the relevant /lib/xorg/modules ;; sub-directories. @@ -240,6 +268,19 @@ EndSection\n" port) port) (newline port) + (let ((layout #$(and=> (xorg-configuration-keyboard-layout config) + keyboard-layout-name)) + (variant #$(and=> (xorg-configuration-keyboard-layout config) + keyboard-layout-variant)) + (model #$(and=> (xorg-configuration-keyboard-layout config) + keyboard-layout-model)) + (options '#$(keyboard-layout-options + (xorg-configuration-keyboard-layout config)))) + (when layout + (display (input-class-section layout variant model options) + port) + (newline port))) + (for-each (lambda (config) (display config port)) '#$(xorg-configuration-extra-config config)))))) -- cgit v1.2.3