mirror of https://github.com/lcpz/lain.git
Merge branch 'master' of https://github.com/copycat-killer/lain
This commit is contained in:
commit
cc88633905
|
@ -32,6 +32,22 @@ local function worker(args)
|
||||||
|
|
||||||
bat.widget = wibox.widget.textbox('')
|
bat.widget = wibox.widget.textbox('')
|
||||||
|
|
||||||
|
bat_notification_low_preset = {
|
||||||
|
title = "Battery low",
|
||||||
|
text = "Plug the cable!",
|
||||||
|
timeout = 15,
|
||||||
|
fg = "#202020",
|
||||||
|
bg = "#CDCDCD"
|
||||||
|
}
|
||||||
|
|
||||||
|
bat_notification_critical_preset = {
|
||||||
|
title = "Battery exhausted",
|
||||||
|
text = "Shutdown imminent",
|
||||||
|
timeout = 15,
|
||||||
|
fg = "#000000",
|
||||||
|
bg = "#FFFFFF"
|
||||||
|
}
|
||||||
|
|
||||||
function update()
|
function update()
|
||||||
bat_now = {
|
bat_now = {
|
||||||
status = "Not present",
|
status = "Not present",
|
||||||
|
@ -96,41 +112,30 @@ local function worker(args)
|
||||||
bat_now.watt = "N/A"
|
bat_now.watt = "N/A"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
widget = bat.widget
|
||||||
|
settings()
|
||||||
|
|
||||||
-- notifications for low and critical states
|
-- notifications for low and critical states
|
||||||
if bat_now.status == "Discharging" and notify == "on"
|
if bat_now.status == "Discharging" and notify == "on"
|
||||||
then
|
then
|
||||||
if tonumber(bat_now.perc) <= 5
|
if tonumber(bat_now.perc) <= 5
|
||||||
then
|
then
|
||||||
bat.id = naughty.notify({
|
bat.id = naughty.notify({
|
||||||
text = "shutdown imminent",
|
preset = bat_notification_critical_preset,
|
||||||
title = "battery nearly exhausted",
|
|
||||||
position = "top_right",
|
|
||||||
timeout = 15,
|
|
||||||
fg="#000000",
|
|
||||||
bg="#ffffff",
|
|
||||||
ontop = true,
|
|
||||||
replaces_id = bat.id
|
replaces_id = bat.id
|
||||||
}).id
|
}).id
|
||||||
elseif tonumber(bat_now.perc) <= 15
|
elseif tonumber(bat_now.perc) <= 15
|
||||||
then
|
then
|
||||||
bat.id = naughty.notify({
|
bat.id = naughty.notify({
|
||||||
text = "plug the cable",
|
preset = bat_notification_low_preset,
|
||||||
title = "battery low",
|
|
||||||
position = "top_right",
|
|
||||||
timeout = 15,
|
|
||||||
fg="#202020",
|
|
||||||
bg="#cdcdcd",
|
|
||||||
ontop = true,
|
|
||||||
replaces_id = bat.id
|
replaces_id = bat.id
|
||||||
}).id
|
}).id
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
widget = bat.widget
|
|
||||||
settings()
|
|
||||||
end
|
|
||||||
|
|
||||||
newtimer("bat", timeout, update)
|
newtimer("bat", timeout, update)
|
||||||
|
|
||||||
return bat.widget
|
return bat.widget
|
||||||
|
|
Loading…
Reference in New Issue