From 726bf16543bd5a0e949aed7e59f9f4b967fdf123 Mon Sep 17 00:00:00 2001 From: aajjbb Date: Mon, 16 May 2016 22:19:26 -0300 Subject: [PATCH] fixing battery percentage going above 100 --- widgets/bat.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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