mirror of
https://github.com/vincentbernat/i3wm-configuration.git
synced 2025-06-24 18:58:33 +02:00
widget: replace previous notification for low battery notification
This commit is contained in:
parent
b5c655050d
commit
45d2260bf7
1 changed files with 15 additions and 13 deletions
|
@ -21,25 +21,27 @@ vicious.register(cpuwidget, vicious.widgets.cpu,
|
||||||
end, 2)
|
end, 2)
|
||||||
|
|
||||||
-- Battery
|
-- Battery
|
||||||
local batwidget = ""
|
local batwidget = { widget = "" }
|
||||||
if config.hostname == "guybrush" then
|
if config.hostname == "guybrush" then
|
||||||
local batlastwarn = nil
|
batwidget.widget = widget({ type = "textbox" })
|
||||||
batwidget = widget({ type = "textbox" })
|
vicious.register(batwidget.widget, vicious.widgets.bat,
|
||||||
vicious.register(batwidget, vicious.widgets.bat,
|
|
||||||
function (widget, args)
|
function (widget, args)
|
||||||
local color = beautiful.fg_widget_value
|
local color = beautiful.fg_widget_value
|
||||||
local current = args[2]
|
local current = args[2]
|
||||||
if current < 10 and args[1] == "-" then
|
if current < 10 and args[1] == "-" then
|
||||||
color = beautiful.fg_widget_value_important
|
color = beautiful.fg_widget_value_important
|
||||||
-- Maybe we want to display a small warning?
|
-- Maybe we want to display a small warning?
|
||||||
if current ~= batlastwarn then
|
if current ~= batwidget.lastwarn then
|
||||||
naughty.notify({ title = "Battery low!",
|
batwidget.lastid = naughty.notify(
|
||||||
preset = naughty.config.presets.critical,
|
{ title = "Battery low!",
|
||||||
text = "Battery level is currently " ..
|
preset = naughty.config.presets.critical,
|
||||||
current .. "%.\n" .. args[3] ..
|
text = "Battery level is currently " ..
|
||||||
" left before running out of power.",
|
current .. "%.\n" .. args[3] ..
|
||||||
icon = "/usr/share/icons/gnome/32x32" ..
|
" left before running out of power.",
|
||||||
"/status/battery-caution.png" })
|
icon = "/usr/share/icons/gnome/32x32" ..
|
||||||
|
"/status/battery-caution.png",
|
||||||
|
replaces_id = batwidget.lastid }).id
|
||||||
|
batwidget.lastwarn = current
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return string.format(
|
return string.format(
|
||||||
|
@ -220,7 +222,7 @@ for s = 1, screen.count() do
|
||||||
on(1, systray), on(1, separator),
|
on(1, systray), on(1, separator),
|
||||||
datewidget, separator,
|
datewidget, separator,
|
||||||
on(2, volwidget), on(2, separator),
|
on(2, volwidget), on(2, separator),
|
||||||
on(2, batwidget), on(2, batwidget ~= "" and separator or ""),
|
on(2, batwidget.widget), on(2, batwidget.widget ~= "" and separator or ""),
|
||||||
on(2, fswidget), on(2, separator),
|
on(2, fswidget), on(2, separator),
|
||||||
on(1, netgraph.widget), on(1, netwidget), on(1, separator),
|
on(1, netgraph.widget), on(1, netwidget), on(1, separator),
|
||||||
on(1, memwidget), on(1, separator),
|
on(1, memwidget), on(1, separator),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue