From d8f3ab5b3734958d727523c6625d5cef73683f4e Mon Sep 17 00:00:00 2001 From: grmat Date: Tue, 23 Jun 2020 02:02:37 +0200 Subject: [PATCH] print_volume: remove hardcoded capture mixer name Try getting playback volume, if it fails try getting capture volume. This prevents not being able to get volume on devices with other mixer names, such as 'Mic'. --- src/print_volume.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/print_volume.c b/src/print_volume.c index 0331ed5a..590f2ede 100644 --- a/src/print_volume.c +++ b/src/print_volume.c @@ -195,14 +195,13 @@ void print_volume(yajl_gen json_gen, char *buffer, const char *fmt, const char * /* Get the volume range to convert the volume later */ snd_mixer_handle_events(m); - if (!strncasecmp(mixer, "capture", strlen("capture"))) { + ALSA_VOLUME(playback) + if (err != 0) { ALSA_VOLUME(capture) - } else { - ALSA_VOLUME(playback) } if (err != 0) { - fprintf(stderr, "i3status: ALSA: Cannot get playback volume.\n"); + fprintf(stderr, "i3status: ALSA: Cannot get volume.\n"); goto out; }