summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGereon Kremer <gereon.kremer@rwth-aachen.de>2013-11-15 00:41:33 +0100
committerMichael Stapelberg <michael@stapelberg.de>2013-11-18 22:31:42 +0100
commit4bd0ba88c896d1ad9beba2eaadc01f1f2d172b5b (patch)
treec1fd550856fe50bc64ed2db853459101c7f2a506 /src
parent09330976e5b08079014087ce0ac490b5b824c8f8 (diff)
Added different format string for volume in case it is muted.
If the volume is muted, the volume level would simply be displayed as zero and the color changed to color_degraded. This patch lets the user define a custom format string for when the volume is muted. The default value is "♪: 0%" ("♪: %volume" being the usual format).
Diffstat (limited to 'src')
-rw-r--r--src/print_volume.c12
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");