From patchwork Tue Feb 4 21:06:32 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sisiutl X-Patchwork-Id: 38206 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 582EB27BBEA; Tue, 4 Feb 2025 21:18:19 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-6.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,FROM_SUSPICIOUS_NTLD,MAILING_LIST_MULTI, PDS_OTHER_BAD_TLD,RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H2, RCVD_IN_VALIDITY_CERTIFIED,RCVD_IN_VALIDITY_RPBL,RCVD_IN_VALIDITY_SAFE, SPF_HELO_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id BB5ED27BBE2 for ; Tue, 4 Feb 2025 21:18:18 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tfQGM-0005aB-Eg; Tue, 04 Feb 2025 16:15:20 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tfQG7-0005ON-2r for guix-patches@gnu.org; Tue, 04 Feb 2025 16:15:04 -0500 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tfQG6-0005l9-PV for guix-patches@gnu.org; Tue, 04 Feb 2025 16:15:02 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:Date:From:To:Subject; bh=TerQRcPRUZEqe10jRat8NnYzOGfBYa2aaM5nc5h/P7E=; b=T5PMXq6tRGHV6gZIAms3qTBGheteoSMSk62S4ijpz4zkkm4GZeI7dumNSl/o9H+ZVwPFPfu7BpIdc75tr0L21+MVW6ILxqGObFlXi3kEd3oB3yVaEMYEX7ga978+1JMIjpwgFZ77wruSh+a1Vx9X/6OyDDt5H9kQXs4roRQe9/NcAmToEhnriIEsFGEi4xYpT2l0yjCintUwRmDSzV7LPuWrzoTT+v+GzppjdNO4o4Vrp/uvI6DE5FQMUcSBCCXh483HCWeIyjIbDK/jseizhSvS4+tq6DM/dvATAZG381MwHazGcipzb5Aczw1cDKT/VdbYJhaUqL76JFluHo7Tng==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tfQG6-0002K0-4F for guix-patches@gnu.org; Tue, 04 Feb 2025 16:15:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#76057] [PATCH] gnu: home: services: Add 'wayland-display' service. Resent-From: Sisiutl Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Tue, 04 Feb 2025 21:15:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 76057 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 76057@debbugs.gnu.org Cc: Sisiutl X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.17387036938873 (code B ref -1); Tue, 04 Feb 2025 21:15:01 +0000 Received: (at submit) by debbugs.gnu.org; 4 Feb 2025 21:14:53 +0000 Received: from localhost ([127.0.0.1]:46922 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tfQFw-0002J2-JO for submit@debbugs.gnu.org; Tue, 04 Feb 2025 16:14:53 -0500 Received: from lists.gnu.org ([2001:470:142::17]:33616) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1tfQFt-0002IS-KP for submit@debbugs.gnu.org; Tue, 04 Feb 2025 16:14:50 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tfQFi-0005Ch-Ng for guix-patches@gnu.org; Tue, 04 Feb 2025 16:14:39 -0500 Received: from 132.86.120.78.rev.sfr.net ([78.120.86.132] helo=fujo.egregore.fun) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tfQFh-0005f5-2Z for guix-patches@gnu.org; Tue, 04 Feb 2025 16:14:38 -0500 Received: from localhost (2a02-8428-4716-0c01-3a87-d5ff-fec3-18bf.rev.sfr.net [IPv6:2a02:8428:4716:c01:3a87:d5ff:fec3:18bf]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (prime256v1) server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) (Authenticated sender: sisiutl@egregore.fun) by fujo.egregore.fun (Postfix) with ESMTPSA id 46D0D6D7D5; Tue, 4 Feb 2025 22:06:42 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=egregore.fun; s=fujo; t=1738703202; bh=TerQRcPRUZEqe10jRat8NnYzOGfBYa2aaM5nc5h/P7E=; h=From:To:Cc:Subject:Date; b=BDN8Edz9v1w4251zVqKxYMHoz8LVJrNzyIFf1Z7ZxehEQc4sN9bfQqVM2UEfQKTsu 36HjmaF5O8Dgpppt6pXF/ynu2b/U2PARnN5Qqnv0oD0YcqZOimhgaMC1IoWHBHP3Eo +J2SPAAnLH49bMw0nEvEeTH3QMqrrrQtRNzhe8x4= From: Sisiutl Date: Tue, 4 Feb 2025 22:06:32 +0100 Message-ID: <20250204210635.19524-1-sisiutl@egregore.fun> X-Mailer: git-send-email 2.48.1 MIME-Version: 1.0 Received-SPF: pass client-ip=78.120.86.132; envelope-from=sisiutl@egregore.fun; helo=fujo.egregore.fun X-Spam_score_int: 56 X-Spam_score: 5.6 X-Spam_bar: +++++ X-Spam_report: (5.6 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FROM_SUSPICIOUS_NTLD=0.499, FROM_SUSPICIOUS_NTLD_FP=1.999, PDS_OTHER_BAD_TLD=0.872, RCVD_IN_PBL=3.335, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, RDNS_DYNAMIC=0.982, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, TVD_RCVD_IP=0.001 autolearn=no autolearn_force=no X-Spam_action: reject 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+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches * gnu/home/services/desktop.scm (wayland-shepherd-service): New procedure. (home-wayland-service-type): New variable. Change-Id: Ide1ca748551a280efe8286b4ac1e46787b108443 --- gnu/home/services/desktop.scm | 68 +++++++++++++++++++++++++++++++++-- 1 file changed, 66 insertions(+), 2 deletions(-) diff --git a/gnu/home/services/desktop.scm b/gnu/home/services/desktop.scm index fc96ce9295..34321409f7 100644 --- a/gnu/home/services/desktop.scm +++ b/gnu/home/services/desktop.scm @@ -48,7 +48,7 @@ (define-module (gnu home services desktop) home-startx-command-service-type)) - + ;;; ;;; Waiting for X11. ;;; @@ -121,7 +121,71 @@ (define home-x11-service-type during that time, the @code{x11-display} service is marked as failing to start."))) - + +;;; +;;; Waiting for Wayland. +;;; + +(define (wayland-shepherd-service config) + (list (shepherd-service + (provision '(wayland-display)) + (modules '((ice-9 ftw) + (ice-9 regex) + (ice-9 match) + (srfi srfi-1) + (shepherd support))) + (respawn? #t) + (respawn-limit (home-wayland-configuration-tries config)) + (respawn-delay 1) + (start + #~(lambda* (#:optional (env-wayland-display (getenv "WAYLAND_DISPLAY"))) + + (define wayland-socket-regex "wayland-[0-9]+$") + + (define (socket? directory regex) + (find (match-lambda + ((or "." "..") #f) + (name + (let ((name (in-vicinity directory + name))) + (and (string-match regex name) + (access? name O_RDWR))))) + ;; Wayland names its sockets `wayland-n`. With + ;; `reverse`, we pick up on the last Wayland instance + ;; created (essentially what we always want to do). + (or (reverse (scandir directory)) '()))) + + (define wayland-display + (or env-wayland-display + (socket? %user-runtime-dir "wayland-[0-9]+$"))) + + (when wayland-display + (format #t "Wayland display found at ~s.~%" wayland-display) + ;; Note: 'make-forkexec-constructor' calls take their + ;; default #:environment-variables value before this service + ;; is started and are thus unaffected by the 'setenv' call + ;; below. Users of this service have to explicitly query + ;; its value. + (setenv "WAYLAND_DISPLAY" wayland-display)) + wayland-display)) + (stop #~(lambda (_) + (unsetenv "WAYLAND_DISPLAY") + #f))))) + +(define-public home-wayland-service-type + (service-type + (name 'home-wayland-display) + (extensions (list (service-extension home-shepherd-service-type + wayland-shepherd-service))) + (default-value 10) + (description + "Create a @code{wayland-display} Shepherd service that waits for a Wayland +compositor to be up and running, up to a configurable delay, and sets the +@code{WAYLAND_DISPLAY} environment variable of @command{shepherd} itself +accordingly. If no accessible Wayland server shows up during that time, the +@code{wayland-display} service is marked as failing to start."))) + + ;;; ;;; Redshift. ;;;