summaryrefslogtreecommitdiff
path: root/gnu/services/sound.scm
diff options
context:
space:
mode:
authorLeo Prikler <leo.prikler@student.tugraz.at>2020-01-10 02:48:19 +0100
committerMarius Bakke <mbakke@fastmail.com>2020-01-11 18:18:50 +0100
commitf547426200d5547268d4a4a8f51c913072fa622f (patch)
treeb5b45e825db3171e0d4189177ae3763360df248c /gnu/services/sound.scm
parent2c7511fb66ef32c0cfd5286719568068d5b226a7 (diff)
downloadpatches-f547426200d5547268d4a4a8f51c913072fa622f.tar
patches-f547426200d5547268d4a4a8f51c913072fa622f.tar.gz
services: Add pulseaudio-configuration.
* gnu/services/sound (<pulseaudio-configuration>): New record. (pulseaudio-etc): New procedure. (pulseaudio-environment): Add PULSE_CONFIG and PULSE_CLIENTCONFIG. (pulseaudio-service-type): Update accordingly. Signed-off-by: Marius Bakke <mbakke@fastmail.com>
Diffstat (limited to 'gnu/services/sound.scm')
-rw-r--r--gnu/services/sound.scm50
1 files changed, 46 insertions, 4 deletions
diff --git a/gnu/services/sound.scm b/gnu/services/sound.scm
index aaca733729..0ac96a02ad 100644
--- a/gnu/services/sound.scm
+++ b/gnu/services/sound.scm
@@ -1,5 +1,6 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2018, 2020 Oleg Pykhalov <go.wigust@gmail.com>
+;;; Copyright © 2020 Leo Prikler <leo.prikler@student.tugraz.at>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -34,6 +35,7 @@
#:export (alsa-configuration
alsa-service-type
+ pulseaudio-configuration
pulseaudio-service-type))
;;; Commentary:
@@ -106,19 +108,59 @@ ctl.!default {
;;; PulseAudio
;;;
+(define-record-type* <pulseaudio-configuration>
+ pulseaudio-configuration make-pulseaudio-configuration
+ pulseaudio-configuration?
+ (client-conf pulseaudio-client-conf
+ (default '()))
+ (daemon-conf pulseaudio-daemon-conf
+ (default '()))
+ (script-file pulseaudio-script-file
+ (default (file-append pulseaudio "/etc/pulse/default.pa")))
+ (system-script-file pulseaudio-system-script-file
+ (default
+ (file-append pulseaudio "/etc/pulse/system.pa"))))
+
(define (pulseaudio-environment config)
;; Define this variable in the global environment such that
;; pulseaudio swh-plugins works.
- `(("LADSPA_PATH"
- . ,(file-append swh-plugins "/lib/ladspa"))))
+ `(("LADSPA_PATH" . ,(file-append swh-plugins "/lib/ladspa"))
+ ;; Define these variables, so that pulseaudio honors /etc.
+ ("PULSE_CONFIG" . "/etc/pulse/daemon.conf")
+ ("PULSE_CLIENTCONFIG" . "/etc/pulse/client.conf")))
+
+(define (pulseaudio-conf-entry arg)
+ (match arg
+ ((key . value)
+ (format #f "~a = ~s~%" key value))
+ ((? string? _)
+ (string-append arg "\n"))))
+
+(define pulseaudio-etc
+ (match-lambda
+ (($ <pulseaudio-configuration> client-conf daemon-conf
+ default-script-file system-script-file)
+ `(("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-script-file "\n"
+ (map pulseaudio-conf-entry daemon-conf)))
+ ("default.pa" ,default-script-file)
+ ("system.pa" ,system-script-file))))))))
(define pulseaudio-service-type
(service-type
(name 'pulseaudio)
(extensions
(list (service-extension session-environment-service-type
- pulseaudio-environment)))
- (default-value #f)
+ pulseaudio-environment)
+ (service-extension etc-service-type pulseaudio-etc)))
+ (default-value (pulseaudio-configuration))
(description "Configure PulseAudio sound support.")))
;;; sound.scm ends here