diff options
author | Adrian C. (anrxc) <anrxc@sysphere.org> | 2009-07-30 02:05:22 +0200 |
---|---|---|
committer | Adrian C. (anrxc) <anrxc@sysphere.org> | 2009-07-30 02:05:22 +0200 |
commit | 2921200d0f1dbf36ae885d0898849a31e646f372 (patch) | |
tree | b4174a0bc74dce3dcbfb309d25593c3e66eea750 /batat.lua | |
parent | e2d503ee36d0e3f0d20f7f888ab03caac68c32bb (diff) | |
download | vicious-legacy-2921200d0f1dbf36ae885d0898849a31e646f372.tar.xz |
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.
Diffstat (limited to 'batat.lua')
-rw-r--r-- | batat.lua | 10 |
1 files changed, 6 insertions, 4 deletions
@@ -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() |