Added handlers to batat and fixed the battery_state table.
Batat now returns "/" in situations where the battery is not present. Last commit broke the battery_state table, fixed that.
This commit is contained in:
parent
e2d503ee36
commit
2921200d0f
10
batat.lua
10
batat.lua
|
@ -19,7 +19,7 @@ function worker(format)
|
|||
local battery_info = {}
|
||||
local battery_state = {
|
||||
["full"] = "*",
|
||||
["unknown"] = " "
|
||||
["unknown"] = " ",
|
||||
["charged"] = "*",
|
||||
["charging"] = "+",
|
||||
["discharging"] = "-"
|
||||
|
@ -33,10 +33,12 @@ function worker(format)
|
|||
-- Check if the battery is present
|
||||
if line:match("^[%s]+Battery.*") then
|
||||
-- Store state and charge information
|
||||
table.insert(battery_info, battery_state[line:match("([%a]*),")])
|
||||
table.insert(battery_info, line:match("([%d]?[%d]?[%d])%."))
|
||||
-- Store remaining time information if the battery supports it
|
||||
table.insert(battery_info, (battery_state[line:match("([%a]*),")] or "/"))
|
||||
table.insert(battery_info, (line:match("([%d]?[%d]?[%d])%.") or "/"))
|
||||
-- Store remaining time information
|
||||
table.insert(battery_info, (line:match("%%,%s(.*)") or "/"))
|
||||
else
|
||||
return { "/", "/", "/" }
|
||||
end
|
||||
end
|
||||
f:close()
|
||||
|
|
Loading…
Reference in New Issue