i3 - improved tiling WM


Added new configuration option "mutediszero" for volume module.

Patch status: rejected

Patch by Gereon Kremer

Long description:

If mutediszero is set to true (default), i3status behaves as previous.
If mutediszero is set to false, the volume level is shown although the mixer is muted.
This is useful in combination with color_degraded where the text is shown in another color if the mixer is muted.

To apply this patch, use:
curl http://cr.i3wm.org/patch/284/raw.patch | git am

b/i3status.c

19
@@ -289,6 +289,7 @@ int main(int argc, char *argv[]) {
20
                 CFG_STR("device", "default", CFGF_NONE),
21
                 CFG_STR("mixer", "Master", CFGF_NONE),
22
                 CFG_INT("mixer_idx", 0, CFGF_NONE),
23
+                CFG_BOOL("mutediszero", true, CFGF_NONE),
24
                 CFG_CUSTOM_COLOR_OPTS,
25
                 CFG_END()
26
         };
27
@@ -515,7 +516,8 @@ int main(int argc, char *argv[]) {
28
                                 print_volume(json_gen, buffer, cfg_getstr(sec, "format"),
29
                                              cfg_getstr(sec, "device"),
30
                                              cfg_getstr(sec, "mixer"),
31
-                                             cfg_getint(sec, "mixer_idx"));
32
+                                             cfg_getint(sec, "mixer_idx"),
33
+                                             cfg_getbool(sec, "mutediszero"));
34
                                 SEC_CLOSE_MAP;
35
                         }
36
 

b/include/i3status.h

41
@@ -156,7 +156,7 @@ void print_cpu_temperature_info(yajl_gen json_gen, char *buffer, int zone, const
42
 void print_cpu_usage(yajl_gen json_gen, char *buffer, const char *format);
43
 void print_eth_info(yajl_gen json_gen, char *buffer, const char *interface, const char *format_up, const char *format_down);
44
 void print_load(yajl_gen json_gen, char *buffer, const char *format, const float max_threshold);
45
-void print_volume(yajl_gen json_gen, char *buffer, const char *fmt, const char *device, const char *mixer, int mixer_idx);
46
+void print_volume(yajl_gen json_gen, char *buffer, const char *fmt, const char *device, const char *mixer, int mixer_idx, bool mutedIsZero);
47
 bool process_runs(const char *path);
48
 
49
 /* socket file descriptor for general purposes */

b/src/print_volume.c

54
@@ -26,7 +26,7 @@
55
 #include "i3status.h"
56
 #include "queue.h"
57
 
58
-void print_volume(yajl_gen json_gen, char *buffer, const char *fmt, const char *device, const char *mixer, int mixer_idx) {
59
+void print_volume(yajl_gen json_gen, char *buffer, const char *fmt, const char *device, const char *mixer, int mixer_idx, bool mutedIsZero) {
60
         char *outwalk = buffer;
61
 	int pbval = 1;
62
 
63
@@ -104,7 +104,7 @@ void print_volume(yajl_gen json_gen, char *buffer, const char *fmt, const char *
64
 			fprintf (stderr, "i3status: ALSA: playback_switch: %s\n", snd_strerror(err));
65
 		if (!pbval)  {
66
 			START_COLOR("color_degraded");
67
-			avg = 0;
68
+			if (mutedIsZero) avg = 0;
69
 		}
70
 	}
71