From: copycat-killer Date: Sun, 26 Jun 2016 18:08:34 +0000 (+0200) Subject: battery: safety checks; #208 X-Git-Url: https://git.madduck.net/etc/awesome.git/commitdiff_plain/86432aa3a2f8c6437ec47e5dd88b110612329e6e battery: safety checks; #208 --- diff --git a/widgets/bat.lua b/widgets/bat.lua index 62016d7..e9ed928 100644 --- a/widgets/bat.lua +++ b/widgets/bat.lua @@ -99,12 +99,12 @@ local function worker(args) bat_now.n_status[i] = first_line(bstr .. "/status") or "N/A" sum_rate_current = sum_rate_current + (rate_current or 0) - sum_rate_voltage = sum_rate_voltage + rate_voltage + sum_rate_voltage = sum_rate_voltage + (rate_voltage or 0) sum_rate_power = sum_rate_power + (rate_power or 0) - sum_rate_energy = sum_rate_energy + (rate_power or ((rate_voltage * rate_current) / 1e6)) + sum_rate_energy = sum_rate_energy + (rate_power or (((rate_voltage or 0) * (rate_current or 0)) / 1e6)) sum_energy_now = sum_energy_now + (energy_now or 0) - sum_energy_full = sum_energy_full + energy_full - sum_energy_percentage = sum_energy_percentage + energy_percentage + sum_energy_full = sum_energy_full + (energy_full or 0) + sum_energy_percentage = sum_energy_percentage + (energy_percentage or 0) end end