From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id KPUeCkz0HGNGpQAAbAwnHQ (envelope-from ) for ; Sat, 10 Sep 2022 22:32:12 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id IDMHCkz0HGMdWQAAauVa8A (envelope-from ) for ; Sat, 10 Sep 2022 22:32:12 +0200 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id DAD3D282A8 for ; Sat, 10 Sep 2022 22:32:11 +0200 (CEST) Received: from localhost ([::1]:42606 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oX798-0001FJ-MI for larch@yhetil.org; Sat, 10 Sep 2022 16:32:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36886) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oX784-0001Dt-A3 for guix-patches@gnu.org; Sat, 10 Sep 2022 16:31:09 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:51732) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oX784-00057N-0B for guix-patches@gnu.org; Sat, 10 Sep 2022 16:31:04 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oX783-0004AV-Rn for guix-patches@gnu.org; Sat, 10 Sep 2022 16:31:03 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#57721] [PATCH 4/4] gnu: base: Add greetd-wlgreet-sway-session. Resent-From: "(" Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sat, 10 Sep 2022 20:31:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 57721 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 57721@debbugs.gnu.org Cc: "\(" Received: via spool by 57721-submit@debbugs.gnu.org id=B57721.166284184815980 (code B ref 57721); Sat, 10 Sep 2022 20:31:03 +0000 Received: (at 57721) by debbugs.gnu.org; 10 Sep 2022 20:30:48 +0000 Received: from localhost ([127.0.0.1]:40428 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oX77o-00049g-0a for submit@debbugs.gnu.org; Sat, 10 Sep 2022 16:30:48 -0400 Received: from knopi.disroot.org ([178.21.23.139]:34586) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oX77g-000491-JQ for 57721@debbugs.gnu.org; Sat, 10 Sep 2022 16:30:44 -0400 Received: from localhost (localhost [127.0.0.1]) by disroot.org (Postfix) with ESMTP id EB11341663; Sat, 10 Sep 2022 22:30:39 +0200 (CEST) X-Virus-Scanned: SPAM Filter at disroot.org Received: from knopi.disroot.org ([127.0.0.1]) by localhost (disroot.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id MlnIYjas7IWf; Sat, 10 Sep 2022 22:30:38 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=disroot.org; s=mail; t=1662841836; bh=fbyjRm10NslwDSgr2z0pbFATbkKg4Y2uLjcrw1nMV7k=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=XYdWSYJ9tzbaqOLT2f6JLUK5OzhS20w/Q/5DJ1hh/+XfjabuywjlwISOYubBZDJ9p 1+ctagdUQhgdgc/39GCD0oAwAQDpEzz+pBZxClJP/7q8edtCPYvzpsFQZPkPI5XNq6 V0OUE81cbW6zu+86lV391UkhFrTaEpfMYDKvR4U8dc1DJdBVt/Bp8irlSAIjRuGo1I 0DZ054kSI2VHPwIICidCmE9kKYLK1Iw8ZOZGoqarGCauJ6degBPb1d5dNsuNl03uBI MazRLKPF3fkJevmZ5ZMZiigfpnfx0RLX8uO42wYHWAQ0wvVm1THpUqDNeQSj071wk1 ue7T5cg6QHdAQ== Date: Sat, 10 Sep 2022 21:30:32 +0100 Message-Id: <20220910203032.17699-4-paren@disroot.org> In-Reply-To: <20220910203032.17699-1-paren@disroot.org> References: <20220910203032.17699-1-paren@disroot.org> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: "Guix-patches" Reply-to: "\(" X-ACL-Warn: , "\( via Guix-patches" From: "\( via Guix-patches" via X-Migadu-Flow: FLOW_IN X-Migadu-To: larch@yhetil.org X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1662841932; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=UJAaWe1d8MEHpaGbkdFjJCcjshrHA4nDgxiAbzjJP3A=; b=eKcLfOvRhyjNnNwb3GydwJbI+jtxF24fy4NALQZ7ER+LhUs66Mzy0JBKyANE0Bpfc4Ntn/ hXKNwECwa3h93haL5innPg2/Q+Jq+5jlQFGOBzkRFHNhEqJQvNWf62c+jxzlfS4fbW4G2c Kh7N1SneJQJ0Lr02wXESdZrr8jGJRn5BYiNccOjnnHKcSSa7+EyGO34yRt/IttXBAV/Ay4 7IWW3NgQJvxhJ8hS/tu2+1+G24ILJa5ZRs2nnsgaHjzgelz3g6EAqw14pschzI1M/NlGFv OOji8jsohuSuYDLfKUW829TFj5Yv3cyGk9Of+wudrBvkvKpcVw8XVOPuowgIfw== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1662841932; a=rsa-sha256; cv=none; b=naOlXDA8VqxXIgyU984fijQ2iDNjZqbeZKhZnFEb4bs7TvBQ73bltFZhEkhXJtGeWYX08t HN1E3QIdJyTuQV7U9YXlvhgoZ0yqzAEszQSGub9f9aMd4CHNf5b1IPz6V07XLZ8NLwkyzj 0DWa/SqdkCZFD4pR2If6v4AGwLK9y2WH51XQjltuZBue8wDErFSV6GRaxxFxqyDIuAA24J UAK+qu+zN1XvXps0ifVXiZD/KukNl4xhNlgocREnHKHnCBkAXcSOpgRgjk1zkaOZs6YIyw Qhg9Pxn682a9oOGkjhnLTg9szZz2F/6349d2nvtVvzIAlAeILM4CJbbn9LcGJQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=disroot.org header.s=mail header.b=XYdWSYJ9; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -2.79 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=disroot.org header.s=mail header.b=XYdWSYJ9; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: DAD3D282A8 X-Spam-Score: -2.79 X-Migadu-Scanner: scn1.migadu.com X-TUID: JFc+9PW3OKo0 * gnu/services/base.scm (greetd-wlgreet-session): New data type. (greetd-wlgreet-sway-session): Likewise. * doc/guix.texi ("Base Services")[greetd-service-type]: Document them. --- doc/guix.texi | 76 ++++++++++++++++++++++++++ gnu/services/base.scm | 122 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 198 insertions(+) diff --git a/doc/guix.texi b/doc/guix.texi index c21235f28d..cf66014d8e 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -106,6 +106,7 @@ Copyright @copyright{} 2022 Philip M@sup{c}Grath@* Copyright @copyright{} 2022 Karl Hallsby@* Copyright @copyright{} 2022 Justin Veilleux@* Copyright @copyright{} 2022 Reily Siegel@* +Copyright @copyright{} 2022 (@* Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or @@ -18633,6 +18634,81 @@ are set right after mentioned variables, so that they can be overriden. @end table @end deftp +@deftp {Data Type} greetd-wlgreet-session +Generic configuration record for the wlgreet greetd greeter. + +@table @asis +@item @code{wlgreet} (default: @code{wlgreet}) +The package with the @command{/bin/wlgreet} command. + +@item @code{command} (default: @code{(file-append sway "/bin/sway")}) +Command to be started by @command{/bin/wlgreet} on successful login. + +@item @code{command-args} (default: @code{'()}) +Command arguments to pass to command. + +@item @code{output-mode} (default: @code{"all"}) +Option to use for @code{outputMode} in the TOML configuration file. + +@item @code{scale} (default: @code{1}) +Option to use for @code{scale} in the TOML configuration file. + +@item @code{background} (default: @code{(list 0 0 0 0.9)}) +RGBA list to use as the background colour of the login prompt. + +@item @code{headline} (default: @code{(list 1 1 1 1)}) +RGBA list to use as the headline colour of the UI popup. + +@item @code{prompt} (default: @code{(list 1 1 1 1)}) +RGBA list to use as the prompt colour of the UI popup. + +@item @code{prompt-error} (default: @code{(list 1 1 1 1)}) +RGBA list to use as the error colour of the UI popup. + +@item @code{border} (default: @code{(list 1 1 1 1)}) +RGBA list to use as the border colour of the UI popup. + +@item @code{extra-env} (default: @code{'()}) +Extra environment variables to set on login. + +@end table +@end deftp + +@deftp {Data Type} greetd-wlgreet-sway-session +Sway-specific configuration record for the wlgreet greetd greeter. + +@table +@item @code{wlgreet-session} (default: @code{(greetd-wlgreet-session)}) +A @code{greetd-wlgreet-session} record for generic wlgreet configuration, +on top of the Sway-specific @code{greetd-wlgreet-sway-session}. + +@item @code{sway} (default: @code{sway}) +The package providing the @command{/bin/sway} command. + +@item @code{sway-configuration} (default: #f) +File-like object providing an additional Sway configuration file to be +prepended to the mandatory part of the configuration. + +@end table + +Here is an example of a greetd configuration that uses wlgreet and Sway: + +@lisp + (greetd-configuration + ;; We need to give the greeter user these permissions, otherwise + ;; Sway will crash on launch. + (greeter-supplementary-groups (list "video" "input" "seat")) + (terminals + (list (greetd-terminal-configuration + (terminal-vt "1") + (terminal-switch #t) + (default-session-command + (greetd-wlgreet-sway-session + (sway-configuration + (local-file "sway-greetd.conf")))))))) +@end lisp +@end deftp + @node Scheduled Job Execution @subsection Scheduled Job Execution diff --git a/gnu/services/base.scm b/gnu/services/base.scm index 616bc42e69..5de4e0a51a 100644 --- a/gnu/services/base.scm +++ b/gnu/services/base.scm @@ -19,6 +19,7 @@ ;;; Copyright © 2021 muradm ;;; Copyright © 2022 Guillaume Le Vaillant ;;; Copyright © 2022 Justin Veilleux +;;; Copyright © 2022 ( ;;; ;;; This file is part of GNU Guix. ;;; @@ -66,6 +67,7 @@ (define-module (gnu services base) #:use-module ((gnu packages gnupg) #:select (guile-gcrypt)) #:use-module (gnu packages linux) #:use-module (gnu packages terminals) + #:use-module ((gnu packages wm) #:select (sway)) #:use-module ((gnu build file-systems) #:select (mount-flags->bit-mask swap-space->flags-bit-mask)) @@ -231,6 +233,8 @@ (define-module (gnu services base) greetd-configuration greetd-terminal-configuration greetd-agreety-session + greetd-wlgreet-session + greetd-wlgreet-sway-session %base-services)) @@ -2869,6 +2873,122 @@ (define (make-greetd-agreety-session-command config command) "agreety-command" #~(execl #$agreety #$agreety "-c" #$command)))) +(define-record-type* + greetd-wlgreet-session make-greetd-wlgreet-session + greetd-wlgreet-session? + (wlgreet greetd-wlgreet (default wlgreet)) + (command greetd-wlgreet-command + (default (file-append sway "/bin/sway"))) + (command-args greetd-wlgreet-command-args (default #~(list))) + (output-mode greetd-wlgreet-output-mode (default "all")) + (scale greetd-wlgreet-scale (default 1)) + (background greetd-wlgreet-background (default (list 0 0 0 0.9))) + (headline greetd-wlgreet-headline (default (list 1 1 1 1))) + (prompt greetd-wlgreet-prompt (default (list 1 1 1 1))) + (prompt-error greetd-wlgreet-prompt-error (default (list 1 1 1 1))) + (border greetd-wlgreet-border (default (list 1 1 1 1))) + (extra-env greetd-wlgreet-extra-env (default #~(list)))) + +(define (greetd-wlgreet-wayland-session-command session) + (program-file "wlgreet-session-command" + #~(let* ((username (getenv "USER")) + (useruid (number->string + (passwd:uid (getpwuid username)))) + (command #$(greetd-wlgreet-command session))) + (use-modules + (ice-9 format) + (ice-9 match)) + (setenv "XDG_SESSION_TYPE" "wayland") + (setenv "XDG_RUNTIME_DIR" + (string-append "/run/user/" useruid)) + (for-each (match-lambda + ((var . val) + (setenv var val))) + #$(greetd-wlgreet-extra-env session)) + (apply execl command command + #$(greetd-wlgreet-command-args session))))) + +(define (make-wlgreet-config-color section-name color) + (match color + ((red green blue opacity) + (string-append + "[" section-name "]\n" + "red = " (number->string red) "\n" + "green = " (number->string green) "\n" + "blue = " (number->string blue) "\n" + "opacity = " (number->string opacity) "\n")))) + +(define (make-wlgreet-configuration-file session) + (let ((command (greetd-wlgreet-wayland-session-command session)) + (output-mode (greetd-wlgreet-output-mode session)) + (scale (greetd-wlgreet-scale session)) + (background (greetd-wlgreet-background session)) + (headline (greetd-wlgreet-headline session)) + (prompt (greetd-wlgreet-prompt session)) + (prompt-error (greetd-wlgreet-prompt-error session)) + (border (greetd-wlgreet-border session))) + (mixed-text-file "wlgreet.toml" + "command = \"" command "\"\n" + "outputMode = \"" output-mode "\"\n" + "scale = " (number->string scale) "\n" + (apply string-append + (map (match-lambda + ((section-name . color) + (make-wlgreet-config-color section-name color))) + `(("background" . ,background) + ("headline" . ,headline) + ("prompt" . ,prompt) + ("prompt-error" . ,prompt-error) + ("border" . ,border))))))) + +(define-record-type* + greetd-wlgreet-sway-session make-greetd-wlgreet-sway-session + greetd-wlgreet-sway-session? + (wlgreet-session greetd-wlgreet-sway-session-wlgreet-session ; + (sway-configuration greetd-wlgreet-sway-session-sway-configuration ;file-like + (default #f))) + +(define (make-wlgreet-sway-configuration-file session) + (let* ((wlgreet-session (greetd-wlgreet-sway-session-wlgreet-session session)) + (wlgreet-config (make-wlgreet-configuration-file wlgreet-session)) + (wlgreet (file-append (greetd-wlgreet wlgreet-session) "/bin/wlgreet")) + (sway-config (greetd-wlgreet-sway-session-sway-configuration session)) + (swaymsg (file-append (greetd-wlgreet-sway-session-sway session) + "/bin/swaymsg"))) + (mixed-text-file "wlgreet-sway.conf" + (if sway-config + #~(string-append "include " #$sway-config "\n") + "") + "xwayland disable\n" + "exec \"" wlgreet " --config " wlgreet-config "; " + swaymsg " exit\"\n"))) + +(define (greetd-wlgreet-sway-session-command session) + (program-file "wlgreet-sway-session-command" + #~(let* ((sway #$(file-append (greetd-wlgreet-sway-session-sway session) + "/bin/sway")) + (config #$(make-wlgreet-sway-configuration-file session)) + (log-file (open-output-file + (string-append "/tmp/sway-greeter." + (number->string (getpid)) + ".log"))) + (username (getenv "USER")) + (useruid (number->string (passwd:uid (getpwuid username))))) + + ;; redirect stdout/err to log-file + (dup2 (fileno log-file) 1) + (dup2 1 2) + + ;; XXX: If we start sway immediately, it won't find seatd for some + ;; reason... + (sleep 1) + + (setenv "XDG_RUNTIME_DIR" (string-append "/run/user/" useruid)) + (execl sway sway "-d" "-c" config)))) + + (define (make-greetd-default-session-command config-or-command) (cond ((greetd-agreety-session? config-or-command) (cond ((greetd-agreety-xdg-env? config-or-command) @@ -2879,6 +2999,8 @@ (define (make-greetd-default-session-command config-or-command) (make-greetd-agreety-session-command config-or-command (greetd-agreety-tty-session-command config-or-command))))) + ((greetd-wlgreet-sway-session? config-or-command) + (greetd-wlgreet-sway-session-command config-or-command)) (#t config-or-command))) (define-record-type* -- 2.37.3