From: Luke Bonham Date: Tue, 16 Aug 2016 10:28:24 +0000 (+0200) Subject: Merge pull request #223 from monokles/bat-perc-fix X-Git-Url: https://git.madduck.net/etc/awesome.git/commitdiff_plain/5e6bcf354cb0e9168078c847d68a5ee919f8e42d?hp=a659d1a4bc99d27a1746985e13f68efc3dd256c7 Merge pull request #223 from monokles/bat-perc-fix [partial] battery: calculate percentage for multiple instances with different capacities --- diff --git a/widgets/bat.lua b/widgets/bat.lua index ec9a289..00d7183 100644 --- a/widgets/bat.lua +++ b/widgets/bat.lua @@ -131,7 +131,7 @@ local function worker(args) local hours = math.floor(rate_time) local minutes = math.floor((rate_time - hours) * 60) - bat_now.perc = tonumber(string.format("%d", math.floor(math.min(100, sum_energy_percentage / #batteries)))) + bat_now.perc = math.floor((sum_energy_now / sum_energy_full) * 100) bat_now.time = string.format("%02d:%02d", hours, minutes) bat_now.watt = tonumber(string.format("%.2f", sum_rate_energy / 1e6)) elseif bat_now.status == "Full" then