Permalink
Browse files

battery/apm-obsd: use adapter state to get charging state

Signed-off-by: Gregor Best <gbe@ring0.de>
  • Loading branch information...
1 parent 9644fa8 commit 97f51cd90546bd6ea85d9604482a4b8b0fc670cf @farhaven farhaven committed Oct 2, 2011
Showing with 8 additions and 8 deletions.
  1. +8 −8 battery/init.lua
View
@@ -108,16 +108,12 @@ local backends = {
end,
["apm-obsd"] = function ()
local rv = {}
- local fd = io.popen("apm -l -b -m")
+ local fd = io.popen("apm -l -a -m")
if not fd then return end
- local fields = { "state", "charge", "time" }
+ local fields = { "charge", "time", "state" }
local states = {
- ["0"] = "high",
- ["1"] = "low",
- ["2"] = "critical",
- ["3"] = "charging",
- ["4"] = "absent",
- ["255"] = "unknown"
+ ["0"] = "discharging",
+ ["1"] = "charging",
}
for line in fd:lines() do
rv[table.remove(fields, 1)] = line
@@ -135,6 +131,10 @@ local backends = {
else
rv.time = tostring(math.floor((rv.time / 60) + 0.5)) .. ":" .. tostring(rv.time % 60)
end
+
+ if tonumber(rv.charge) >= 98 and rv.state == "charging" then
+ rv.state = "full"
+ end
return rv
end
}

0 comments on commit 97f51cd

Please sign in to comment.