From: Luke Bonham Date: Tue, 17 May 2016 15:30:37 +0000 (+0200) Subject: Merge pull request #197 from aajjbb/master X-Git-Url: https://git.madduck.net/etc/awesome.git/commitdiff_plain/6fd1eecd4399caa2d3a411420bc9f9994f3b7cce?hp=5f847c7ecbad5345ab1bd8ad359b9e16b7913407 Merge pull request #197 from aajjbb/master fixing battery percentage going above 100 --- diff --git a/widgets/bat.lua b/widgets/bat.lua index 152fa12..43b7a5f 100644 --- a/widgets/bat.lua +++ b/widgets/bat.lua @@ -13,7 +13,7 @@ local first_line = require("lain.helpers").first_line local naughty = require("naughty") local wibox = require("wibox") -local math = { floor = math.floor } +local math = { floor = math.floor, min = math.min } local string = { format = string.format } local tonumber = tonumber @@ -98,7 +98,7 @@ local function worker(args) local minutes = math.floor((rate_time - hours) * 60) local watt = rate_power and (rate_power / 1e6) or (rate_voltage * rate_current) / 1e12 - bat_now.perc = string.format("%d", energy_percentage) + bat_now.perc = string.format("%d", math.min(100, energy_percentage)) bat_now.time = string.format("%02d:%02d", hours, minutes) bat_now.watt = string.format("%.2fW", watt) end