mirror of https://github.com/lcpz/lain.git
fixing issue in case of nil rate_power in bat widget
This commit is contained in:
parent
49d493e1a4
commit
6cd0a29535
|
@ -96,15 +96,17 @@ local function worker(args)
|
|||
if bat_now.status == "Charging" then
|
||||
rate_time = (energy_full - energy_now) / rate_power or rate_current
|
||||
elseif bat_now.status == "Discharging" then
|
||||
rate_time = energy_now / rate_power or rate_current
|
||||
rate_time = energy_now / (rate_power or rate_current)
|
||||
end
|
||||
|
||||
local hours = math.floor(rate_time)
|
||||
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.time = string.format("%02d:%02d", hours, minutes)
|
||||
bat_now.watt = string.format("%.2fW", rate_power / 1e6 or (rate_voltage * rate_current) / 1e12)
|
||||
bat_now.watt = string.format("%.2fW", watt)
|
||||
end
|
||||
|
||||
widget = bat.widget
|
||||
|
|
Loading…
Reference in New Issue