[wiki] [sites] [slstatus][patch][alsa] add mute support || sewn

From: <git_AT_suckless.org>
Date: Thu, 31 Aug 2023 14:07:34 +0200

commit 1a021e0beb9efaae3b23af0743d5c4f288592833
Author: sewn <sewn_AT_disroot.org>
Date: Thu Aug 31 15:06:05 2023 +0300

    [slstatus][patch][alsa] add mute support

diff --git a/tools.suckless.org/slstatus/patches/alsa/index.md b/tools.suckless.org/slstatus/patches/alsa/index.md
index 3d91c524..3d642254 100644
--- a/tools.suckless.org/slstatus/patches/alsa/index.md
+++ b/tools.suckless.org/slstatus/patches/alsa/index.md
_AT_@ -15,7 +15,11 @@ Download
 --------
 * [slstatus-alsa-4bd78c9.patch](slstatus-alsa-4bd78c9.patch)
 
+For adding support regarding mute status:
+* [slstatus-alsa-mute-1.0.diff](slstatus-alsa-mute-1.0.diff)
+
 Authors
 -------
 * Ivan Krylov <krylov.r00t_AT_gmail.com>
 * drkhsh <me_AT_drkhsh.at>
+* sewn <sewn_AT_disroot.org> (mute support)
diff --git a/tools.suckless.org/slstatus/patches/alsa/slstatus-alsa-mute-1.0.diff b/tools.suckless.org/slstatus/patches/alsa/slstatus-alsa-mute-1.0.diff
new file mode 100644
index 00000000..db70c19a
--- /dev/null
+++ b/tools.suckless.org/slstatus/patches/alsa/slstatus-alsa-mute-1.0.diff
_AT_@ -0,0 +1,46 @@
+From 8375f197e9af7d219abe65cf0311ea16dea852f1 Mon Sep 17 00:00:00 2001
+From: sewn <sewn_AT_disroot.org>
+Date: Thu, 31 Aug 2023 15:01:07 +0300
+Subject: [PATCH] volume: add mute support for ALSA
+
+---
+ components/volume.c | 10 ++++++++--
+ 1 file changed, 8 insertions(+), 2 deletions(-)
+
+diff --git a/components/volume.c b/components/volume.c
+index 15c5a39..8636f61 100644
+--- a/components/volume.c
++++ b/components/volume.c
+_AT_@ -193,7 +193,7 @@
+ snd_mixer_selem_id_t *mixid = NULL;
+ snd_mixer_elem_t *elem = NULL;
+ long min = 0, max = 0, volume = -1;
+- int err;
++ int err, sw1, sw2;
+
+ if ((err = snd_mixer_open(&mixer, 0))) {
+ warn("snd_mixer_open: %d", err);
+_AT_@ -229,13 +229,19 @@
+ if ((err = snd_mixer_selem_get_playback_volume(elem, SND_MIXER_SCHN_MONO, &volume))) {
+ warn("snd_mixer_selem_get_playback_volume(): %d", err);
+ }
++ if ((err = snd_mixer_selem_get_playback_switch(elem, 0, &sw1))) {
++ warn("snd_mixer_selem_get_playback_switch(): %d", err);
++ }
++ if ((err = snd_mixer_selem_get_playback_switch(elem, 1, &sw2))) {
++ warn("snd_mixer_selem_get_playback_switch(): %d", err);
++ }
+
+ cleanup:
+ snd_mixer_free(mixer);
+ snd_mixer_detach(mixer, devname);
+ snd_mixer_close(mixer);
+
+- return volume == -1 ? NULL : bprintf("%.0f", (volume-min)*100./(max-min));
++ return !(sw1 || sw2) ? "mute" : volume == -1 ? NULL : bprintf("%.0f", (volume-min)*100./(max-min));
+ }
+ #else
+ #include <sys/soundcard.h>
+--
+2.42.0
+
Received on Thu Aug 31 2023 - 14:07:34 CEST

This archive was generated by hypermail 2.3.0 : Thu Aug 31 2023 - 14:13:16 CEST