]> git.sur5r.net Git - i3/i3status/commitdiff
turn volume into red if muted
authorSimon Elsbrock <simon@iodev.org>
Wed, 5 Sep 2012 16:39:47 +0000 (18:39 +0200)
committerMichael Stapelberg <michael@stapelberg.de>
Wed, 5 Sep 2012 21:28:27 +0000 (23:28 +0200)
fixes #743

src/print_volume.c

index dbf5e1ff02022f521f05c3cc4dd428911593fb07..95a36014e1a68308b7602b743fad6ca968922c1f 100644 (file)
@@ -152,12 +152,14 @@ void print_volume(yajl_gen json_gen, char *buffer, const char *fmt, const char *
        } else avg = (int)val;
 
        /* Check for mute */
+       int pbval;
        if (snd_mixer_selem_has_playback_switch(hdl->elem)) {
-               int pbval;
                if ((err = snd_mixer_selem_get_playback_switch(hdl->elem, 0, &pbval)) < 0)
                        fprintf (stderr, "i3status: ALSA: playback_switch: %s\n", snd_strerror(err));
-               if (!pbval)
+               if (!pbval)  {
+                       START_COLOR("color_bad");
                        avg = 0;
+               }
        }
 
        const char *walk = fmt;
@@ -199,4 +201,7 @@ void print_volume(yajl_gen json_gen, char *buffer, const char *fmt, const char *
 
         *outwalk = '\0';
         OUTPUT_FULL_TEXT(buffer);
+
+        if (!pbval)
+               END_COLOR;
 }