diff options
author | Marius Bakke <mbakke@fastmail.com> | 2020-01-11 22:38:24 +0100 |
---|---|---|
committer | Marius Bakke <mbakke@fastmail.com> | 2020-01-11 22:38:24 +0100 |
commit | b7bf02a418e946b610ef68e8c5131f2350835956 (patch) | |
tree | 6d84387279b9870dc0b151bb9d3dce7f9d9de73d /gnu/services/sound.scm | |
parent | 233c1be0a30846f6646b1f4edc6257037d0835fc (diff) | |
parent | 13efb24850bc40fab2448771c87c77c9a69fc231 (diff) | |
download | guix-patches-b7bf02a418e946b610ef68e8c5131f2350835956.tar guix-patches-b7bf02a418e946b610ef68e8c5131f2350835956.tar.gz |
Merge branch 'master' into core-updates
Diffstat (limited to 'gnu/services/sound.scm')
-rw-r--r-- | gnu/services/sound.scm | 101 |
1 files changed, 99 insertions, 2 deletions
diff --git a/gnu/services/sound.scm b/gnu/services/sound.scm index f2dd24402f..a1c928222a 100644 --- a/gnu/services/sound.scm +++ b/gnu/services/sound.scm @@ -1,5 +1,6 @@ ;;; GNU Guix --- Functional package management for GNU -;;; Copyright © 2018 Oleg Pykhalov <go.wigust@gmail.com> +;;; 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. ;;; @@ -21,16 +22,24 @@ #:use-module (gnu services configuration) #:use-module (gnu services shepherd) #:use-module (gnu services) + #:use-module (gnu system pam) #:use-module (gnu system shadow) #:use-module (guix gexp) #:use-module (guix packages) #:use-module (guix records) #:use-module (guix store) + #:use-module (gnu packages audio) #:use-module (gnu packages linux) #:use-module (gnu packages pulseaudio) #:use-module (ice-9 match) #:export (alsa-configuration - alsa-service-type)) + alsa-service-type + + pulseaudio-configuration + pulseaudio-service-type + + ladspa-configuration + ladspa-service-type)) ;;; Commentary: ;;; @@ -97,4 +106,92 @@ ctl.!default { (default-value (alsa-configuration)) (description "Configure low-level Linux sound support, ALSA."))) + +;;; +;;; PulseAudio +;;; + +(define-record-type* <pulseaudio-configuration> + pulseaudio-configuration make-pulseaudio-configuration + pulseaudio-configuration? + (client-conf pulseaudio-client-conf + (default '())) + (daemon-conf pulseaudio-daemon-conf + ;; Flat volumes may cause unpleasant experiences to users + ;; when applications inadvertently max out the system volume + ;; (see e.g. <https://bugs.gnu.org/38172>). + (default '((flat-volumes . no)))) + (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 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) + (service-extension etc-service-type pulseaudio-etc))) + (default-value (pulseaudio-configuration)) + (description "Configure PulseAudio sound support."))) + + +;;; +;;; LADSPA +;;; + +(define-record-type* <ladspa-configuration> + ladspa-configuration make-ladspa-configuration + ladspa-configuration? + (plugins ladspa-plugins (default '()))) + +(define (ladspa-environment config) + ;; Define this variable in the global environment such that + ;; pulseaudio swh-plugins (and similar LADSPA plugins) work. + `(("LADSPA_PATH" . + (string-join + ',(map (lambda (package) (file-append package "/lib/ladspa")) + (ladspa-plugins config)) + ":")))) + +(define ladspa-service-type + (service-type + (name 'ladspa) + (extensions + (list (service-extension session-environment-service-type + ladspa-environment))) + (default-value (ladspa-configuration)) + (description "Configure LADSPA plugins."))) + ;;; sound.scm ends here |