]> git.sur5r.net Git - i3/i3status/commitdiff
Volume percentage should be obtained by float division and rounded to int. 76/head
authorJakub Klinkovský <j.l.k@gmx.com>
Mon, 12 Oct 2015 07:44:13 +0000 (09:44 +0200)
committerJakub Klinkovský <j.l.k@gmx.com>
Mon, 12 Oct 2015 07:44:13 +0000 (09:44 +0200)
Fixes #75

Makefile
src/pulse.c

index 5667c0d6a16323d8a6fdde345bb6e73a5606e1df..dca4f71be6b5fa047254bec1ad373844e0648b25 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -22,6 +22,7 @@ CFLAGS+=-Iinclude
 LIBS+=-lconfuse
 LIBS+=-lyajl
 LIBS+=-lpulse
+LIBS+=-lm
 
 VERSION:=$(shell git describe --tags --abbrev=0)
 GIT_VERSION:="$(shell git describe --tags --always) ($(shell git log --pretty=format:%cd --date=short -n1))"
index 5a381a0bdc107f07966d54a47563775994a54cd1..34e302b110302e7aa687fd875817256e343be6eb 100644 (file)
@@ -1,6 +1,7 @@
 // vim:ts=4:sw=4:expandtab
 #include <string.h>
 #include <stdio.h>
+#include <math.h>
 #include <pulse/pulseaudio.h>
 #include "i3status.h"
 #include "queue.h"
@@ -78,7 +79,7 @@ static void store_volume_from_sink_cb(pa_context *c,
         return;
 
     int avg_vol = pa_cvolume_avg(&info->volume);
-    int vol_perc = (int)((long long)avg_vol * 100 / PA_VOLUME_NORM);
+    int vol_perc = roundf((float)avg_vol * 100 / PA_VOLUME_NORM);
     int composed_volume = COMPOSE_VOLUME_MUTE(vol_perc, info->mute);
 
     /* if this is the default sink we must try to save it twice: once with