[bug#76289,v3,2/2] services: Add speakersafetyd service.
Commit Message
* gnu/services/sound.scm (speakersafetyd-service-type) New variable.
* doc/guix.texi: Document the speakersafetyd service.
Change-Id: Ib8fa19b056a2036019ae7c199d81e1139664e951
---
doc/guix.texi | 42 +++++++++++++++++++++++++++
gnu/services/sound.scm | 65 +++++++++++++++++++++++++++++++++++++++++-
2 files changed, 106 insertions(+), 1 deletion(-)
Comments
Hi,
Roman Scherer <roman@burningswell.com> writes:
> * gnu/services/sound.scm (speakersafetyd-service-type) New variable.
> * doc/guix.texi: Document the speakersafetyd service.
>
> Change-Id: Ib8fa19b056a2036019ae7c199d81e1139664e951
I've made the following small adjustments:
--8<---------------cut here---------------start------------->8---
modified doc/guix.texi
@@ -26593,6 +26593,7 @@ Sound Services
See below for details about @code{speakersafetyd-configuration}.
@end defvar
+@c %start of fragment
@deftp {Data Type} speakersafetyd-configuration
Available @code{speakersafetyd-configuration} fields are:
@@ -26608,14 +26609,14 @@ Sound Services
contains the configuration files of the speaker models.
@item @code{maximum-gain-reduction} (default: @code{7}) (type: integer)
-Maximum gain reduction before panicing, useful for debugging.
+Maximum gain reduction before panicking, useful for debugging.
@item @code{speakersafetyd} (default: @code{speakersafetyd}) (type: file-like)
The Speaker Safety Daemon package to use.
@end table
-
@end deftp
+@c %end of fragment
@node File Search Services
@subsection File Search Services
modified gnu/services/sound.scm
@@ -3,6 +3,7 @@
;;; Copyright © 2020 Liliana Marie Prikler <liliana.prikler@gmail.com>
;;; Copyright © 2020 Marius Bakke <mbakke@fastmail.com>
;;; Copyright © 2022 Maxim Cournoyer <maxim.cournoyer@gmail.com>
+;;; Copyright © 2025 Roman Scherer <roman@burningswell.com>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -274,7 +275,7 @@ (define ladspa-service-type
;;;
-;;; Speaker Safety Daemon
+;;; Speaker Safety Daemon.
;;;
(define-configuration/no-serialization speakersafetyd-configuration
@@ -289,7 +290,7 @@ (define-configuration/no-serialization speakersafetyd-configuration
the configuration files of the speaker models.")
(maximum-gain-reduction
(integer 7)
- "Maximum gain reduction before panicing, useful for debugging.")
+ "Maximum gain reduction before panicking, useful for debugging.")
(speakersafetyd
(file-like speakersafetyd)
"The Speaker Safety Daemon package to use."))
--8<---------------cut here---------------end--------------->8---
And expound the changelog a bit to:
--8<---------------cut here---------------start------------->8---
services: Add speakersafetyd service.
* gnu/services/sound.scm (speakersafetyd-shepherd-service)
(speakersafetyd-configuration)
(speakersafetyd-service-type): New variables.
* doc/guix.texi (Sound Services): Document it.
--8<---------------cut here---------------end--------------->8---
And pushed as commit af643735a5.
Thank you for your contribution! Closing by replying to
76289-done@debbugs.gnu.org in CC.
@@ -26575,6 +26575,48 @@ Sound Services
@end defvar
+@subsubheading Speaker Safety Daemon System Service
+
+@uref{https://github.com/AsahiLinux/speakersafetyd, Speaker Safety
+Daemon} is a user-space daemon that implements an analogue of the Texas
+Instruments Smart Amp speaker protection model. It can be used to
+protect the speakers on Apple Silicon devices.
+
+@defvar speakersafetyd-service-type
+This is the type for the @code{speakersafetyd} system service, whose
+value is a @command{speakersafetyd-configuration} record.
+
+@lisp
+(service speakersafetyd-service-type)
+@end lisp
+
+See below for details about @code{speakersafetyd-configuration}.
+@end defvar
+
+@deftp {Data Type} speakersafetyd-configuration
+Available @code{speakersafetyd-configuration} fields are:
+
+@table @asis
+@item @code{blackbox-directory} (default: @code{"/var/lib/speakersafetyd/blackbox"}) (type: string)
+The directory to which blackbox files are written when the speakers are
+getting too hot. The blackbox files contain audio and debug information
+which the developers of @code{speakersafetyd} might ask for when
+reporting bugs.
+
+@item @code{configuration-directory} (type: file-like)
+The base directory as a G-expression (@pxref{G-Expressions}) that
+contains the configuration files of the speaker models.
+
+@item @code{maximum-gain-reduction} (default: @code{7}) (type: integer)
+Maximum gain reduction before panicing, useful for debugging.
+
+@item @code{speakersafetyd} (default: @code{speakersafetyd}) (type: file-like)
+The Speaker Safety Daemon package to use.
+
+@end table
+
+@end deftp
+
@node File Search Services
@subsection File Search Services
@@ -35,6 +35,7 @@ (define-module (gnu services sound)
#:use-module (gnu packages audio)
#:use-module (gnu packages linux)
#:use-module (gnu packages pulseaudio)
+ #:use-module (gnu packages rust-apps)
#:use-module (ice-9 match)
#:use-module (srfi srfi-1)
#:export (alsa-configuration
@@ -56,7 +57,15 @@ (define-module (gnu services sound)
ladspa-configuration
ladspa-configuration?
ladspa-configuration-plugins
- ladspa-service-type))
+ ladspa-service-type
+
+ speakersafetyd-configuration
+ speakersafetyd-configuration-blackbox-directory
+ speakersafetyd-configuration-configuration-directory
+ speakersafetyd-configuration-maximum-gain-reduction
+ speakersafetyd-configuration-speakersafetyd
+ speakersafetyd-configuration?
+ speakersafetyd-service-type))
;;; Commentary:
;;;
@@ -263,4 +272,58 @@ (define ladspa-service-type
(default-value (ladspa-configuration))
(description "Configure LADSPA plugins.")))
+
+;;;
+;;; Speaker Safety Daemon
+;;;
+
+(define-configuration/no-serialization speakersafetyd-configuration
+ (blackbox-directory
+ (string "/var/lib/speakersafetyd/blackbox")
+ "The directory to which blackbox files are written when the speakers are
+getting too hot. The blackbox files contain audio and debug information which
+the developers of @code{speakersafetyd} might ask for when reporting bugs.")
+ (configuration-directory
+ (file-like (file-append speakersafetyd "/share/speakersafetyd"))
+ "The base directory as a G-expression (@pxref{G-Expressions}) that contains
+the configuration files of the speaker models.")
+ (maximum-gain-reduction
+ (integer 7)
+ "Maximum gain reduction before panicing, useful for debugging.")
+ (speakersafetyd
+ (file-like speakersafetyd)
+ "The Speaker Safety Daemon package to use."))
+
+(define speakersafetyd-shepherd-service
+ (match-record-lambda <speakersafetyd-configuration>
+ (blackbox-directory configuration-directory maximum-gain-reduction speakersafetyd)
+ (shepherd-service
+ (documentation "Run the speaker safety daemon")
+ (provision '(speakersafetyd))
+ (requirement '(udev))
+ (start #~(make-forkexec-constructor
+ (list #$(file-append speakersafetyd "/bin/speakersafetyd")
+ "--config-path" #$configuration-directory
+ "--blackbox-path" #$blackbox-directory
+ "--max-reduction" (number->string #$maximum-gain-reduction))))
+ (stop #~(make-kill-destructor)))))
+
+(define speakersafetyd-service-type
+ (service-type
+ (name 'speakersafetyd)
+ (description "Run @command{speakersafetyd}, a user space daemon that
+implements an analogue of the Texas Instruments Smart Amp speaker protection
+model. It can be used to protect the speakers on Apple Silicon devices.")
+ (extensions
+ (list (service-extension
+ shepherd-root-service-type
+ (compose list speakersafetyd-shepherd-service))
+ (service-extension
+ udev-service-type
+ (compose list speakersafetyd-configuration-speakersafetyd))
+ (service-extension
+ profile-service-type
+ (compose list speakersafetyd-configuration-speakersafetyd))))
+ (default-value (speakersafetyd-configuration))))
+
;;; sound.scm ends here