summaryrefslogtreecommitdiff
path: root/src/print_volume.c
diff options
context:
space:
mode:
authorBaptiste Daroussin <bapt@FreeBSD.org>2013-03-19 18:23:59 +0100
committerMichael Stapelberg <michael@stapelberg.de>2013-03-19 18:36:49 +0100
commit7f83d0a1976ebdba7f8671ba74b472ad5b4839b1 (patch)
treec0a9887329e611d67fec2f98fc933178719fbd9a /src/print_volume.c
parent5e0b8812bfdd3c128bdbfc022d4eb25a4b0d2490 (diff)
Show degraded colors in case volume is muted with OSS
Diffstat (limited to 'src/print_volume.c')
-rw-r--r--src/print_volume.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/print_volume.c b/src/print_volume.c
index cf42f3e..1b03e5e 100644
--- a/src/print_volume.c
+++ b/src/print_volume.c
@@ -177,6 +177,7 @@ void print_volume(yajl_gen json_gen, char *buffer, const char *fmt, const char *
#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__DragonFly__)
char mixerpath[] = "/dev/mixer";
int mixfd, vol, devmask = 0;
+ pbval = 1;
if ((mixfd = open(mixerpath, O_RDWR)) < 0)
return;
@@ -185,6 +186,11 @@ void print_volume(yajl_gen json_gen, char *buffer, const char *fmt, const char *
if (ioctl(mixfd, MIXER_READ(0),&vol) == -1)
return;
+ if (((vol & 0x7f) == 0) && (((vol >> 8) & 0x7f) == 0)) {
+ START_COLOR("color_degraded");
+ pbval = 0;
+ }
+
const char *walk = fmt;
for (; *walk != '\0'; walk++) {
if (*walk != '%') {