summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorparazyd <parazyd@dyne.org>2016-12-30 12:16:07 +0100
committerparazyd <parazyd@dyne.org>2016-12-30 12:16:07 +0100
commit62f40164309cd6f22be9fae89c071221944618e4 (patch)
tree8dd70436266950dc3b3e98af8c353dc4d738b5c2
parentc2808b6d99f30e30b059906e7801cc8a2b76189f (diff)
add vol_perc notes, add braces to singleline statements
-rw-r--r--README.md10
-rw-r--r--config.def.h2
-rw-r--r--slstatus.c12
3 files changed, 19 insertions, 5 deletions
diff --git a/README.md b/README.md
index 27a4a10..93b7b12 100644
--- a/README.md
+++ b/README.md
@@ -50,6 +50,16 @@ If you use any other status bar or window manager you will have to figure it out
slstatus -o | other_status_bar &
+### Specific function quirks
+
+- Volume percentage
+
+If there is no `/dev/mixer` on your system and you use ALSA, it means you have to load the OSS compatibility module by issuing:
+
+```
+# modprobe snd-pcm-oss
+```
+
## Contributing
Hunt FIXME's in the code or do WTF you want! If it is useful, I will merge.
diff --git a/config.def.h b/config.def.h
index 4ce5958..caddd7f 100644
--- a/config.def.h
+++ b/config.def.h
@@ -34,7 +34,7 @@
- uid (uid of current user) [argument: NULL]
- uptime (uptime) [argument: NULL]
- username (username of current user) [argument: NULL]
-- vol_perc (oss/alsa volume and mute status in percent) [argument: /dev/mixer]
+- vol_perc (oss/alsa volume status (see README)) [argument: /dev/mixer]
- wifi_perc (wifi signal in percent) [argument: wifi card interface name]
- wifi_essid (wifi essid) [argument: wifi card interface name] */
static const struct arg args[] = {
diff --git a/slstatus.c b/slstatus.c
index d580ac0..ff81e0c 100644
--- a/slstatus.c
+++ b/slstatus.c
@@ -628,14 +628,18 @@ vol_perc(const char *card)
}
ioctl(afd, MIXER_READ(SOUND_MIXER_DEVMASK), &devmask);
- for (i = 0; i < (sizeof(vnames) / sizeof((vnames[0]))); i++)
- if (devmask & (1 << i))
- if (!strcmp("vol", vnames[i]))
+ for (i = 0; i < (sizeof(vnames) / sizeof((vnames[0]))); i++) {
+ if (devmask & (1 << i)) {
+ if (!strcmp("vol", vnames[i])) {
ioctl(afd, MIXER_READ(i), &v);
+ }
+ }
+ }
close(afd);
- if (v == 0)
+ if (v == 0) {
return smprintf("mute");
+ }
return smprintf("%d%%", v & 0xff);
}