status

statusbar program for dwm
git clone anongit@rnpnr.xyz:status.git
Log | Files | Refs | Feed | README | LICENSE

Commit: 5128e601c19450ee71a1308d28c4b9a812ff9358
Parent: 50ea68722f668eab82fc7ace7464de7f4de5affe
Author: Randy Palamar
Date:   Sun,  4 Apr 2021 17:13:55 -0600

remove useless snprintf buf calls in getvol()

Diffstat:
Mblocks/volume.c | 15++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/blocks/volume.c b/blocks/volume.c @@ -17,6 +17,7 @@ getvol(struct Block *b) snd_mixer_t *handle; snd_mixer_selem_id_t *sid; snd_mixer_elem_t *elem; + const char *str = "muted"; int notmuted; long vol, min, max; @@ -43,14 +44,14 @@ getvol(struct Block *b) snd_mixer_selem_id_free(sid); if (notmuted) { - if (abs(vol) < 100) + /* HACK: digital out is always 100% so just say on */ + if (abs(vol) < 100) { snprintf(buf, sizeof(buf), "%d%%", (int)vol); - else - /* HACK: digital out is always 100% so just say on */ - snprintf(buf, sizeof(buf), "%s", "on"); - } else - snprintf(buf, sizeof(buf), "%s", "muted"); + str = buf; + } else + str = "on"; + } - return snprintf(b->curstr, LEN(b->curstr), b->fmt, buf); + return snprintf(b->curstr, LEN(b->curstr), b->fmt, str); } #endif