unofficial mirror of bug-guix@gnu.org 
 help / color / mirror / code / Atom feed
From: Leo Prikler <leo.prikler@student.tugraz.at>
To: 38172@debbugs.gnu.org
Subject: bug#38172: fixing dangerous PulseAudio defaults and giving it a record type
Date: Tue, 12 Nov 2019 12:00:40 +0100	[thread overview]
Message-ID: <e90cdf58363f0462005527cc765a02abe481e5ef.camel@student.tugraz.at> (raw)
In-Reply-To: <20191111220941.09cae111@riseup.net>

[-- Attachment #1: Type: text/plain, Size: 2 bytes --]



[-- Attachment #2: 0001-services-Add-PulseAudio-service.patch --]
[-- Type: text/x-patch, Size: 3094 bytes --]

From d48594a3e7e02aef0c5ff9fff719c1d0fb45207e Mon Sep 17 00:00:00 2001
From: Leo Prikler <leo.prikler@student.tugraz.at>
Date: Tue, 12 Nov 2019 02:08:40 +0100
Subject: [PATCH] services: Add PulseAudio service

* gnu/services/sound.scm: (<pulseaudio-configuration>): New record type.
(pulseaudio-service-type): New service type.
---
 gnu/services/sound.scm | 58 +++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 57 insertions(+), 1 deletion(-)

diff --git a/gnu/services/sound.scm b/gnu/services/sound.scm
index f2dd24402f..2aedc03c75 100644
--- a/gnu/services/sound.scm
+++ b/gnu/services/sound.scm
@@ -30,7 +30,9 @@
   #:use-module (gnu packages pulseaudio)
   #:use-module (ice-9 match)
   #:export (alsa-configuration
-            alsa-service-type))
+            alsa-service-type
+            pulseaudio-configuration
+            pulseaudio-service-type))
 
 ;;; Commentary:
 ;;;
@@ -97,4 +99,58 @@ ctl.!default {
    (default-value (alsa-configuration))
    (description "Configure low-level Linux sound support, ALSA.")))
 
+\f
+;;;
+;;; PulseAudio
+;;;
+
+(define-record-type* <pulseaudio-configuration>
+  pulseaudio-configuration make-pulseaudio-configuration
+  pulseaudio-configuration?
+  (package pulseaudio-package (default pulseaudio))
+  (client-conf pulseaudio-client-conf (default '()))
+  (daemon-conf pulseaudio-daemon-conf (default '((flat-volumes no))))
+  (default-script pulseaudio-default-script (default #f))
+  (system-script pulseaudio-system-script (default #f)))
+
+(define (pulseaudio-conf-entry arg)
+  (match arg
+    ((key value)
+     (format #f "~a = ~a~%" key value))
+    ((? string? _)
+     (string-append arg "\n"))))
+
+(define pulseaudio-etc-service
+  (match-lambda
+    (($ <pulseaudio-configuration> package client-conf daemon-conf
+                                   default-script system-script)
+     (let ((default.pa (if default-script
+                           (apply mixed-text-file "default.pa"
+                                  default-script)
+                           (file-append package "/etc/pulse/default.pa"))))
+       `(("pulse"
+          ,(file-union
+            "pulse"
+            `(("client.conf"
+               ,(apply mixed-text-file "client.conf"
+                       (map pulseaudio-conf-entry client-conf)))
+              ("daemon.conf"
+               ,(apply mixed-text-file "daemon.conf"
+                       "default-script-file = " default.pa "\n"
+                       (map pulseaudio-conf-entry daemon-conf)))
+              ("default.pa" ,default.pa)
+              ("system.pa"
+               ,(if default-script
+                    (apply mixed-text-file "system.pa"
+                           system-script)
+                    (file-append package "/etc/pulse/system.pa")))))))))))
+
+(define pulseaudio-service-type
+  (service-type
+   (name 'pulseaudio)
+   (extensions
+    (list (service-extension etc-service-type pulseaudio-etc-service)))
+   (default-value (pulseaudio-configuration))
+   (description "Configure PulseAudio.")))
+
 ;;; sound.scm ends here
-- 
2.24.0


  reply	other threads:[~2019-11-12 11:01 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <e9aba2fd590811bda70b65036f682b764c7141cf.camel@student.tugraz.at>
2019-11-11 21:09 ` bug#38172: fixing dangerous PulseAudio defaults and giving it a record type raingloom
2019-11-12 11:00   ` Leo Prikler [this message]
2020-01-09  1:22   ` bug#38172: WebkitGTK-based browsers: System volume suddenly maxed out when playing audio or video Leo Prikler
2020-01-09 20:48     ` Marius Bakke
2020-01-09 22:49       ` Leo Prikler
2020-01-11 16:48         ` Marius Bakke

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e90cdf58363f0462005527cc765a02abe481e5ef.camel@student.tugraz.at \
    --to=leo.prikler@student.tugraz.at \
    --cc=38172@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).