summary refs log tree commit diff
path: root/gnu/services/sound.scm
diff options
context:
space:
mode:
authorOleg Pykhalov <go.wigust@gmail.com>2018-04-28 13:30:20 +0300
committerOleg Pykhalov <go.wigust@gmail.com>2018-05-02 15:11:13 +0300
commit8cd1e8e84926dc6ed1012a17609dea2d20ac41b4 (patch)
treed61e6475db179223c3e5983446aa2aa1c300684b /gnu/services/sound.scm
parentfb5b359d7715f85334dd3efdf72512b2a46caa47 (diff)
downloadguix-8cd1e8e84926dc6ed1012a17609dea2d20ac41b4.tar.gz
gnu: Add sound service.
* gnu/services/sound.scm: New file.
* gnu/local.mk (GNU_SYSTEM_MODULES): Add this.
* doc/guix.texi (Sound Services): New chapter.
Diffstat (limited to 'gnu/services/sound.scm')
-rw-r--r--gnu/services/sound.scm86
1 files changed, 86 insertions, 0 deletions
diff --git a/gnu/services/sound.scm b/gnu/services/sound.scm
new file mode 100644
index 0000000000..5fe555e8b6
--- /dev/null
+++ b/gnu/services/sound.scm
@@ -0,0 +1,86 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2018 Oleg Pykhalov <go.wigust@gmail.com>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (gnu services sound)
+  #:use-module (gnu services base)
+  #:use-module (gnu services configuration)
+  #:use-module (gnu services shepherd)
+  #:use-module (gnu services)
+  #: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 pulseaudio)
+  #:use-module (ice-9 match)
+  #:export (alsa-configuration
+            alsa-service-type))
+
+;;; Commentary:
+;;;
+;;; Sound services.
+;;;
+;;; Code:
+
+
+;;;
+;;; ALSA
+;;;
+
+(define-record-type* <alsa-configuration>
+  alsa-configuration make-alsa-configuration alsa-configuration?
+  (pulseaudio?   alsa-configuration-pulseaudio? ;boolean
+                 (default #t))
+  (extra-options alsa-configuration-extra-options ;string
+                 (default "")))
+
+(define (alsa-config-file config)
+  "Return the ALSA configuration file corresponding to CONFIG."
+  (plain-file "asound.conf"
+              (string-append "# Generated by 'alsa-service'.\n\n"
+                             (if (alsa-configuration-pulseaudio? config)
+                                 "# Use PulseAudio by default
+pcm.!default {
+  type pulse
+  fallback \"sysdefault\"
+  hint {
+    show on
+    description \"Default ALSA Output (currently PulseAudio Sound Server)\"
+  }
+}
+
+ctl.!default {
+  type pulse
+  fallback \"sysdefault\"
+}
+"
+                                 "")
+                             (alsa-configuration-extra-options config))))
+
+(define (alsa-etc-service config)
+  (list `("asound.conf" ,(alsa-config-file config))))
+
+(define alsa-service-type
+  (service-type
+   (name 'alsa)
+   (extensions
+    (list (service-extension etc-service-type alsa-etc-service)))
+   (default-value (alsa-configuration))
+   (description "Configure low-level Linux sound support, ALSA.")))
+
+;;; sound.scm ends here