silence warnings when battery is <15%, but charging

This commit is contained in:
Conor Heine 2013-09-26 16:01:09 -04:00
parent ab17a2d496
commit 82dd3effca
2 changed files with 54 additions and 48 deletions

View File

@ -74,30 +74,33 @@ local function worker(args)
bat_now.watt = string.format("%.2fW", (rate * ratev) / 1e12) bat_now.watt = string.format("%.2fW", (rate * ratev) / 1e12)
-- notifications for low and critical states -- notifications for low and critical states
if bat_now.perc <= 5 if bat_new.status == "Discharging"
then then
bat.id = naughty.notify({ if bat_now.perc <= 5
text = "shutdown imminent", then
title = "battery nearly exhausted", bat.id = naughty.notify({
position = "top_right", text = "shutdown imminent",
timeout = 15, title = "battery nearly exhausted",
fg="#000000", position = "top_right",
bg="#ffffff", timeout = 15,
ontop = true, fg="#000000",
replaces_id = bat.id bg="#ffffff",
}).id ontop = true,
elseif bat_now.perc <= 15 replaces_id = bat.id
then }).id
bat.id = naughty.notify({ elseif bat_now.perc <= 15
text = "plug the cable", then
title = "battery low", bat.id = naughty.notify({
position = "top_right", text = "plug the cable",
timeout = 15, title = "battery low",
fg="#202020", position = "top_right",
bg="#cdcdcd", timeout = 15,
ontop = true, fg="#202020",
replaces_id = bat.id bg="#cdcdcd",
}).id ontop = true,
replaces_id = bat.id
}).id
end
end end
bat_now.perc = string.format("%d", bat_now.perc) bat_now.perc = string.format("%d", bat_now.perc)

View File

@ -113,36 +113,39 @@ function tpbat.register(args)
if bat:installed() if bat:installed()
then then
bat_now.status = bat:status() bat_now.status = bat:status() or "N/A"
bat_now.perc = bat:percent() bat_now.perc = bat:percent()
bat_now.time = bat:remaining_time() bat_now.time = bat:remaining_time()
-- bat_now.watt = string.format("%.2fW", (VOLTS * AMPS) / 1e12) -- bat_now.watt = string.format("%.2fW", (VOLTS * AMPS) / 1e12)
-- notifications for low and critical states -- notifications for low and critical states (when discharging)
if bat_now.perc <= 5 if bat_now.status == "discharging"
then then
tpbat.id = naughty.notify({ if bat_now.perc <= 5
text = "shutdown imminent", then
title = "battery nearly exhausted", tpbat.id = naughty.notify({
position = "top_right", text = "shutdown imminent",
timeout = 15, title = "battery nearly exhausted",
fg="#000000", position = "top_right",
bg="#ffffff", timeout = 15,
ontop = true, fg="#000000",
replaces_id = tpbat.id bg="#ffffff",
}).id ontop = true,
elseif bat_now.perc <= 15 replaces_id = tpbat.id
then }).id
tpbat.id = naughty.notify({ elseif bat_now.perc <= 15
text = "plug the cable", then
title = "battery low", tpbat.id = naughty.notify({
position = "top_right", text = "plug the cable",
timeout = 15, title = "battery low",
fg="#202020", position = "top_right",
bg="#cdcdcd", timeout = 15,
ontop = true, fg="#202020",
replaces_id = tpbat.id bg="#cdcdcd",
}).id ontop = true,
replaces_id = tpbat.id
}).id
end
end end
bat_now.perc = tostring(bat_now.perc) bat_now.perc = tostring(bat_now.perc)