From patchwork Wed Apr 3 09:44:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Ludovic_Court=C3=A8s?= X-Patchwork-Id: 3191 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id C126C16CE0; Wed, 3 Apr 2019 10:45:11 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.0 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTP id 37A8916CD2 for ; Wed, 3 Apr 2019 10:45:11 +0100 (BST) Received: from localhost ([127.0.0.1]:43455 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hBcSE-0001q9-PO for patchwork@mira.cbaines.net; Wed, 03 Apr 2019 05:45:10 -0400 Received: from eggs.gnu.org ([209.51.188.92]:58973) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hBcS9-0001oH-49 for guix-patches@gnu.org; Wed, 03 Apr 2019 05:45:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hBcS7-0002cf-Mc for guix-patches@gnu.org; Wed, 03 Apr 2019 05:45:04 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:56791) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hBcS7-0002cO-Hk for guix-patches@gnu.org; Wed, 03 Apr 2019 05:45:03 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1hBcS7-00059N-Fa for guix-patches@gnu.org; Wed, 03 Apr 2019 05:45:03 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#35118] [PATCH 4/4] services: Add 'localed' service type and have GDM extend it. Resent-From: Ludovic =?utf-8?q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 03 Apr 2019 09:45:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 35118 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 35118@debbugs.gnu.org Received: via spool by 35118-submit@debbugs.gnu.org id=B35118.155428468419732 (code B ref 35118); Wed, 03 Apr 2019 09:45:03 +0000 Received: (at 35118) by debbugs.gnu.org; 3 Apr 2019 09:44:44 +0000 Received: from localhost ([127.0.0.1]:42099 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hBcRo-000587-3f for submit@debbugs.gnu.org; Wed, 03 Apr 2019 05:44:44 -0400 Received: from eggs.gnu.org ([209.51.188.92]:44471) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hBcRg-00057J-BL for 35118@debbugs.gnu.org; Wed, 03 Apr 2019 05:44:36 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:50866) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hBcRb-0001RH-2f; Wed, 03 Apr 2019 05:44:31 -0400 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=60528 helo=gnu.org) by fencepost.gnu.org with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1hBcRa-0000ni-Ix; Wed, 03 Apr 2019 05:44:30 -0400 From: Ludovic =?utf-8?q?Court=C3=A8s?= Date: Wed, 3 Apr 2019 11:44:19 +0200 Message-Id: <20190403094419.22802-4-ludo@gnu.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190403094419.22802-1-ludo@gnu.org> References: <20190403094419.22802-1-ludo@gnu.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches This fixes a bug whereby GDM would always switch to US English keyboard layout regardless to the configured Xorg keyboard layout. * gnu/services/xorg.scm (): New record type. (localed-dbus-service): New procedure. (localed-service-type): New variable. (gdm-service-type): Extend LOCALED-SERVICE-TYPE. --- gnu/services/xorg.scm | 89 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 88 insertions(+), 1 deletion(-) diff --git a/gnu/services/xorg.scm b/gnu/services/xorg.scm index 29c7f30013..7745f9a3cc 100644 --- a/gnu/services/xorg.scm +++ b/gnu/services/xorg.scm @@ -27,6 +27,7 @@ #:use-module (gnu services shepherd) #:use-module (gnu system pam) #:use-module (gnu system keyboard) + #:use-module (gnu services base) #:use-module (gnu services dbus) #:use-module ((gnu packages base) #:select (canonical-package)) #:use-module (gnu packages guile) @@ -35,6 +36,7 @@ #:use-module (gnu packages gl) #:use-module (gnu packages glib) #:use-module (gnu packages display-managers) + #:use-module (gnu packages freedesktop) #:use-module (gnu packages gnustep) #:use-module (gnu packages gnome) #:use-module (gnu packages admin) @@ -91,6 +93,10 @@ screen-locker-service-type screen-locker-service + localed-configuration + localed-configuration? + localed-service-type + gdm-configuration gdm-service-type gdm-service)) @@ -653,6 +659,82 @@ makes the good ol' XlockMore usable." (file-append package "/bin/" program) allow-empty-passwords?))) + +;;; +;;; Locale service. +;;; + +(define-record-type* + localed-configuration make-localed-configuration + localed-configuration? + (localed localed-configuration-localed + (default localed)) + (keyboard-layout localed-configuration-keyboard-layout + (default #f))) + +(define (localed-dbus-service config) + "Return the 'localed' D-Bus service for @var{config}, a +@code{} record." + (define keyboard-layout + (localed-configuration-keyboard-layout config)) + + ;; The primary purpose of 'localed' is to tell GDM what the "current" Xorg + ;; keyboard layout is. If 'localed' is missing, or if it's unable to + ;; determine the current XKB layout, then GDM forcefully installs its + ;; default XKB config (US English). Here we communicate the configured + ;; layout through environment variables. + + (if keyboard-layout + (let* ((layout (keyboard-layout-name keyboard-layout)) + (variant (keyboard-layout-variant keyboard-layout)) + (model (keyboard-layout-model keyboard-layout)) + (options (keyboard-layout-options keyboard-layout))) + (list (wrapped-dbus-service + (localed-configuration-localed config) + "libexec/localed/localed" + `(("GUIX_XKB_LAYOUT" ,layout) + ,@(if variant + `(("GUIX_XKB_VARIANT" ,variant)) + '()) + ,@(if model + `(("GUIX_XKB_MODEL" ,model)) + '()) + ,@(if (null? options) + '() + `(("GUIX_XKB_OPTIONS" + ,(string-join options ",")))))))) + (localed-configuration-localed config))) + +(define localed-service-type + (let ((package (compose list localed-configuration-localed))) + (service-type (name 'localed) + (extensions + (list (service-extension dbus-root-service-type + localed-dbus-service) + (service-extension udev-service-type package) + (service-extension polkit-service-type package) + + ;; Add 'localectl' to the profile. + (service-extension profile-service-type package))) + + ;; This service can be extended, typically by the X login + ;; manager, to communicate the chosen Xorg keyboard layout. + (compose first) + (extend (lambda (config keyboard-layout) + (localed-configuration + (inherit config) + (keyboard-layout keyboard-layout)))) + (description + "Run the locale daemon, @command{localed}, which can be used +to control the system locale and keyboard mapping from user programs such as +the GNOME desktop environment.") + (default-value (localed-configuration))))) + + +;;; +;;; GNOME Desktop Manager. +;;; + (define %gdm-accounts (list (user-group (name "gdm") (system? #t)) (user-account @@ -787,7 +869,12 @@ makes the good ol' XlockMore usable." gdm-configuration-gnome-shell-assets) (service-extension dbus-root-service-type (compose list - gdm-configuration-gdm)))) + gdm-configuration-gdm)) + (service-extension localed-service-type + (compose + xorg-configuration-keyboard-layout + gdm-configuration-xorg)))) + (default-value (gdm-configuration)) (description "Run the GNOME Desktop Manager (GDM), a program that allows