From 611e863ace93c18a71697bb9a3f8ffa18f03da6d Mon Sep 17 00:00:00 2001 From: Jakub Klinkovský Date: Mon, 12 Oct 2015 09:44:13 +0200 Subject: Volume percentage should be obtained by float division and rounded to int. Fixes #75 --- src/pulse.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/pulse.c') diff --git a/src/pulse.c b/src/pulse.c index 5a381a0..34e302b 100644 --- a/src/pulse.c +++ b/src/pulse.c @@ -1,6 +1,7 @@ // vim:ts=4:sw=4:expandtab #include #include +#include #include #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 -- cgit v1.2.3