diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/print_volume.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/print_volume.c b/src/print_volume.c index d84b3ec..493167a 100644 --- a/src/print_volume.c +++ b/src/print_volume.c @@ -26,7 +26,7 @@ #include "i3status.h" #include "queue.h" -void print_volume(yajl_gen json_gen, char *buffer, const char *fmt, const char *device, const char *mixer, int mixer_idx) { +void print_volume(yajl_gen json_gen, char *buffer, const char *fmt, const char *fmt_muted, const char *device, const char *mixer, int mixer_idx) { char *outwalk = buffer; int pbval = 1; @@ -104,7 +104,7 @@ void print_volume(yajl_gen json_gen, char *buffer, const char *fmt, const char * fprintf (stderr, "i3status: ALSA: playback_switch: %s\n", snd_strerror(err)); if (!pbval) { START_COLOR("color_degraded"); - avg = 0; + fmt = fmt_muted; } } @@ -117,6 +117,10 @@ void print_volume(yajl_gen json_gen, char *buffer, const char *fmt, const char * *(outwalk++) = *walk; continue; } + if (BEGINS_WITH(walk+1, "%")) { + outwalk += sprintf(outwalk, "%%"); + walk += strlen("%"); + } if (BEGINS_WITH(walk+1, "volume")) { outwalk += sprintf(outwalk, "%d%%", avg); walk += strlen("volume"); @@ -156,6 +160,10 @@ void print_volume(yajl_gen json_gen, char *buffer, const char *fmt, const char * *(outwalk++) = *walk; continue; } + if (BEGINS_WITH(walk+1, "%")) { + outwalk += sprintf(outwalk, "%%"); + walk += strlen("%"); + } if (BEGINS_WITH(walk+1, "volume")) { outwalk += sprintf(outwalk, "%d%%", vol & 0x7f); walk += strlen("volume"); |