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 ms0.migadu.com with LMTPS id QDKCEEO1+GFS2QAAgWs5BA (envelope-from ) for ; Tue, 01 Feb 2022 05:21:23 +0100 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 aKkJDUO1+GHzPQEAauVa8A (envelope-from ) for ; Tue, 01 Feb 2022 05:21:23 +0100 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 89343232F7 for ; Tue, 1 Feb 2022 05:21:22 +0100 (CET) Received: from localhost ([::1]:37108 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nEkfR-0003xs-PU for larch@yhetil.org; Mon, 31 Jan 2022 23:21:21 -0500 Received: from eggs.gnu.org ([209.51.188.92]:47512) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nEkf8-0003vo-37 for guix-patches@gnu.org; Mon, 31 Jan 2022 23:21:02 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:48547) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nEkf7-0006QY-Ou for guix-patches@gnu.org; Mon, 31 Jan 2022 23:21:01 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nEkf7-0003T2-LV for guix-patches@gnu.org; Mon, 31 Jan 2022 23:21:01 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#53676] [PATCH 4/5] services: pulseaudio: Add an extra-script-files configuration field. Resent-From: Maxim Cournoyer Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Tue, 01 Feb 2022 04:21:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 53676 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 53676@debbugs.gnu.org Cc: Maxim Cournoyer Received: via spool by 53676-submit@debbugs.gnu.org id=B53676.164368920913227 (code B ref 53676); Tue, 01 Feb 2022 04:21:01 +0000 Received: (at 53676) by debbugs.gnu.org; 1 Feb 2022 04:20:09 +0000 Received: from localhost ([127.0.0.1]:41448 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nEkeH-0003RG-2Y for submit@debbugs.gnu.org; Mon, 31 Jan 2022 23:20:09 -0500 Received: from mail-qk1-f170.google.com ([209.85.222.170]:40497) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nEkeA-0003Pw-UA for 53676@debbugs.gnu.org; Mon, 31 Jan 2022 23:20:04 -0500 Received: by mail-qk1-f170.google.com with SMTP id o25so14087617qkj.7 for <53676@debbugs.gnu.org>; Mon, 31 Jan 2022 20:20:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=A85CY8mxBoZfFcgwbkuf9MlS6T51uhQ10luPAjoKQWU=; b=dquLpMiT9mDy+00dmvn1/hUIm2f3Vdp6qcQugJ9gm+EhalQCXEplwTr1S1tD9pUHXq Wl4qEBNLli1ploWUuYGb8gAvCHlPxLtlIoOT72JMEcBxpOpM4mm4M370fle7hpQD0Z2Y glECS0k3cNH2EMpjovUCK4UreCbs8QBNjv/+8bsFUasds31p0HuC8zabu8fXWg7EA+7q nYb9SwyFCybnfIs0ZBiQe+XP+hqCkty9Xci+3u2SSfyeRmHRzAdwiM1lVDiqkZqNjNMX Gw4ziw9deh/ZdTcWy78JvXNZNTZowCSM+Sj/OhXjOJEa31vHkUMb7V9HoiAwkcct3y2g yhNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=A85CY8mxBoZfFcgwbkuf9MlS6T51uhQ10luPAjoKQWU=; b=hq1fRc/yYo4ZWDga3j0y2eWpk1JrcclvkYkBV5XgN6bfopnBiS9C9JoONL9MyZyJ6i RZWSc2TcDduqpkqV6LU6qcYjSaJoId4CPDRdECuPmWy9BU3cLlovRRF9zKcFkioCNyp2 lVzk9JFQjHSaQd/VoNlhBM8UlajBG9DrpJvc7unz4pQEAchyMnqclu3J9fyZS5BsFwsl 4JJcLFXG8V6uGlpImXFiWOifRMtMBI/dMdQbrOfoFDeJBJLfn+KKgIB2UOviISdUbpbQ 9hRPcpX/e+aDQdAgrz852YlzC9rW/3qoTRj0JuiVh+P4wUcRyFrowhKPZShFLw2mZNRd 9XFg== X-Gm-Message-State: AOAM531lz3WCwSwheRJ9pflaTrllbn1z5Xhm8oIq99RqMz8298k43Vbu g68kHYNS7IhEu4sNFENKCiz+5INpuJ4= X-Google-Smtp-Source: ABdhPJyAxjtBqmb7upEF8ca79VB18KuIp60DkDQeVGVRTTqUr6L7jP15DyHbBXEQGmfmY8zFRgrwjQ== X-Received: by 2002:a05:620a:24c9:: with SMTP id m9mr15376253qkn.125.1643689197300; Mon, 31 Jan 2022 20:19:57 -0800 (PST) Received: from localhost.localdomain (dsl-10-141-111.b2b2c.ca. [72.10.141.111]) by smtp.gmail.com with ESMTPSA id a8sm9192439qti.71.2022.01.31.20.19.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Jan 2022 20:19:56 -0800 (PST) From: Maxim Cournoyer Date: Mon, 31 Jan 2022 23:19:32 -0500 Message-Id: <20220201041933.16603-4-maxim.cournoyer@gmail.com> X-Mailer: git-send-email 2.34.0 In-Reply-To: <20220201041933.16603-1-maxim.cournoyer@gmail.com> References: <20220201041933.16603-1-maxim.cournoyer@gmail.com> MIME-Version: 1.0 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" X-Migadu-Flow: FLOW_IN X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1643689282; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: 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=A85CY8mxBoZfFcgwbkuf9MlS6T51uhQ10luPAjoKQWU=; b=SyTh/xPueP31goSbDKaRbYO4V+93TcE0aUQGy12nSRVvuHZVXd4ifGjdUO2/Nq05SihHXu 2gEU3bYiwAksdErgY4bYyaubPPigoxGjGmM1ZnBb3upMy3UXGH6sIVI0tQUOeo4pr1DzXV 3jfROOXbTdQEd3mp4ym3UtXNCgtyg36JHTlh9LrWZ6SplhS6IGLjHfGJLYgC6M0dd5LKBm GH8HEVHLF+mevCReDai+IEjtwnS4ikLfkbxRS8LAMQhki/tVydSoSjpZIcGWfdZ0stS7g3 hTAG9bHgOM6cifWrsyoj6RfI/mn8fR6iCE5+31hT3TNrkJ4c+waUm6auPAKV+Q== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1643689282; a=rsa-sha256; cv=none; b=GonXWuPYe6AbuccSph6047/jEmj12VAzq5thwmmYMQ0idX/OUBLxeG67w/QYm9tVP/5MI5 Iap+voO+f7o4vT4ABfDlKotA/TAZayW1+Pm1DbJbLSwM6Dqq6Jq6kNt+PXsGr13ZxL7v7N kQUs1OLyeutelfC6nJh8kMf/Id1CeuKbvLrx4cGj+10vlqat2i2KiW/JQLX69q9/3wGpnI +tNDOJ209Ehgcmg7BdCIBYGETXMzJ3HRqwKUccvaPYjRdzIykuqpYgvUm2k4/2B3OC41E8 cx1s5X7w8GS9b8GDP+pkQB+4F5JaRJxshyQHB8aqg4UMN8oWn9VPZ9kDLcvZAQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20210112 header.b=dquLpMiT; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); 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: -1.53 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20210112 header.b=dquLpMiT; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); 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: 89343232F7 X-Spam-Score: -1.53 X-Migadu-Scanner: scn1.migadu.com X-TUID: xGkRt7qW0wqS * gnu/services/sound.scm () [extra-script-files]: Add field. (extra-script-files->file-union): Add procedure. (pulseaudio-etc): Use it. * doc/guix.texi: Document it. --- doc/guix.texi | 27 +++++++++++++++++++++++++++ gnu/services/sound.scm | 19 +++++++++++++++++-- 2 files changed, 44 insertions(+), 2 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index a002670030..2f8df03461 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -21393,9 +21393,36 @@ List of settings to set in @file{daemon.conf}, formatted just like @item @code{script-file} (default: @code{(file-append pulseaudio "/etc/pulse/default.pa")}) Script file to use as @file{default.pa}. +@item @code{extra-script-files} (default: @code{'())}) +A list of file-like objects defining extra PulseAudio scripts to run at +the initialization of the @command{pulseaudio} daemon. For a reference +of the available commands, refer to @command{man pulse-cli-syntax}. + @item @code{system-script-file} (default: @code{(file-append pulseaudio "/etc/pulse/system.pa")}) Script file to use as @file{system.pa}. @end table + +The example below sets the default PulseAudio card profile, the default +sink and the default source to use for a old SoundBlaster Audigy sound +card: +@lisp +(pulseaudio-configuration + (extra-script-files + (list (plain-file "configure-audigy-card" + (string-append "\ +set-card-profile alsa_card.pci-0000_01_01.0 \ + output:analog-surround-40+input:analog-mono +set-default-source alsa_input.pci-0000_01_01.0.analog-mono +set-default-sink alsa_output.pci-0000_01_01.0.analog-surround-40\n"))))) +@end lisp + +Note that @code{pulseaudio-service-type} is part of +@code{%desktop-services}; if your operating system declaration was +derived from one of the desktop templates, you'll want to adjust the +above example to modify the existing @code{pulseaudio-service-type} via +@code{modify-services} (@pxref{Service Reference, +@code{modify-services}}), instead of defining a new one. + @end deftp @deffn {Scheme Variable} ladspa-service-type diff --git a/gnu/services/sound.scm b/gnu/services/sound.scm index 19eccfc860..f529188a7c 100644 --- a/gnu/services/sound.scm +++ b/gnu/services/sound.scm @@ -34,6 +34,7 @@ (define-module (gnu services sound) #:use-module (gnu packages linux) #:use-module (gnu packages pulseaudio) #:use-module (ice-9 match) + #:use-module (srfi srfi-1) #:export (alsa-configuration alsa-service-type @@ -125,6 +126,8 @@ (define-record-type* (default '((flat-volumes . no)))) (script-file pulseaudio-configuration-script-file (default (file-append pulseaudio "/etc/pulse/default.pa"))) + (extra-script-files pulseaudio-configuration-extra-script-files + (default '())) (system-script-file pulseaudio-configuration-system-script-file (default (file-append pulseaudio "/etc/pulse/system.pa")))) @@ -145,14 +148,26 @@ (define pulseaudio-environment ("PULSE_CLIENTCONFIG" . ,(apply mixed-text-file "client.conf" (map pulseaudio-conf-entry client-conf))))))) +(define (extra-script-files->file-union extra-script-files) + "Return a G-exp obtained by processing EXTRA-SCRIPT-FILES with FILE-UNION. +Each file is named \"snippet-n.pa\", where N is their 1-offset index." + (let ((labels (map (lambda (n) (format #f "snippet-~a.pa" n)) + (iota (length extra-script-files) 1)))) + (file-union "default.pa.d" (zip labels extra-script-files)))) + (define pulseaudio-etc (match-lambda - (($ _ _ default-script-file system-script-file) + (($ _ _ default-script-file extra-script-files + system-script-file) `(("pulse" ,(file-union "pulse" `(("default.pa" ,default-script-file) - ("system.pa" ,system-script-file)))))))) + ("system.pa" ,system-script-file) + ,@(if (null? extra-script-files) + '() + `(("default.pa.d" ,(extra-script-files->file-union + extra-script-files))))))))))) (define pulseaudio-service-type (service-type -- 2.34.0