Merge pull request #257 from bssb/master

prevent battery widget from crashing by ignoring null capacity field of Logitech mice
This commit is contained in:
streetturtle 2021-04-26 15:46:35 -04:00 committed by GitHub
commit 864b224492
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 5 deletions

View File

@ -142,12 +142,14 @@ local function worker(user_args)
local charge = 0
local status
for i, batt in ipairs(battery_info) do
if batt.charge >= charge then
status = batt.status -- use most charged battery status
-- this is arbitrary, and maybe another metric should be used
end
if capacities[i] ~= nil then
if batt.charge >= charge then
status = batt.status -- use most charged battery status
-- 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
charge = charge / capacity