diff options
author | Adrian C. (anrxc) <anrxc@sysphere.org> | 2009-10-15 23:38:55 +0200 |
---|---|---|
committer | Adrian C. (anrxc) <anrxc@sysphere.org> | 2009-10-16 16:53:31 +0200 |
commit | 25ce79e4e5c5bad03359ddaa3ca8b3ceb91f2c4f (patch) | |
tree | 7deec95ef7e7a6e9955a54229d55effba7cd4ce5 | |
parent | baa361282886afbdc720afec72aa552fb9ef1f78 (diff) | |
download | vicious-legacy-25ce79e4e5c5bad03359ddaa3ca8b3ceb91f2c4f.tar.xz |
batat: better returns when handling insufficient data
If we return "N/A" like we usually do then format string "$1$2" would
look like "N/AN/A". If "/" is returned a progressbar could be
broken. Now returns are: symbol for state "unknown", 0 for battery
charge, N/A for remaining time.
-rw-r--r-- | batat.lua | 8 |
1 files changed, 4 insertions, 4 deletions
@@ -33,12 +33,12 @@ local function worker(format) -- Check if the battery is present if string.match(line, "^[%s]+Battery.*") then -- Store state and charge information - table.insert(battery_info, (battery_state[string.match(line, "([%a]*),")] or "/")) - table.insert(battery_info, (string.match(line, "([%d]?[%d]?[%d])%.") or "/")) + table.insert(battery_info, (battery_state[string.match(line, "([%a]*),") or "unknown"])) + table.insert(battery_info, (string.match(line, "([%d]?[%d]?[%d])%.") or "0")) -- Store remaining time information - table.insert(battery_info, (string.match(line, "%%,%s(.*)") or "/")) + table.insert(battery_info, (string.match(line, "%%,%s(.*)") or "N/A")) else - return {"/", "/", "/"} + return {battery_state["unknown"], "0", "N/A"} end end f:close() |