prevent battery widget from crashing by ignoring null capacity field of Logitech mice
This commit is contained in:
parent
9d9f435f21
commit
700b4e1f55
|
@ -142,12 +142,14 @@ local function worker(user_args)
|
||||||
local charge = 0
|
local charge = 0
|
||||||
local status
|
local status
|
||||||
for i, batt in ipairs(battery_info) do
|
for i, batt in ipairs(battery_info) do
|
||||||
if batt.charge >= charge then
|
if capacities[i] ~= nil then
|
||||||
status = batt.status -- use most charged battery status
|
if batt.charge >= charge then
|
||||||
-- this is arbitrary, and maybe another metric should be used
|
status = batt.status -- use most charged battery status
|
||||||
end
|
-- this is arbitrary, and maybe another metric should be used
|
||||||
|
end
|
||||||
|
|
||||||
charge = charge + batt.charge * capacities[i]
|
charge = charge + batt.charge * capacities[i]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
charge = charge / capacity
|
charge = charge / capacity
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue