mirror of
https://github.com/vincentbernat/i3wm-configuration.git
synced 2025-07-01 22:04:20 +02:00
widget: display a warning when running out of battery
This commit is contained in:
parent
0880df4fc7
commit
fa7d139a30
1 changed files with 12 additions and 1 deletions
|
@ -23,13 +23,24 @@ vicious.register(cpuwidget, vicious.widgets.cpu,
|
||||||
-- Battery
|
-- Battery
|
||||||
local batwidget = ""
|
local batwidget = ""
|
||||||
if config.hostname == "guybrush" then
|
if config.hostname == "guybrush" then
|
||||||
|
local batlastwarn = nil
|
||||||
batwidget = widget({ type = "textbox" })
|
batwidget = widget({ type = "textbox" })
|
||||||
vicious.register(batwidget, 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 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?
|
||||||
|
if current ~= batlastwarn then
|
||||||
|
naughty.notify({ title = "Battery low!",
|
||||||
|
preset = naughty.config.presets.critical,
|
||||||
|
text = "Battery level is currently " ..
|
||||||
|
current .. "%.\n" .. args[3] ..
|
||||||
|
" left before running out of power.",
|
||||||
|
icon = "/usr/share/icons/gnome/32x32" ..
|
||||||
|
"/status/battery-caution.png" })
|
||||||
|
end
|
||||||
end
|
end
|
||||||
return string.format(
|
return string.format(
|
||||||
'<span font="Terminus 8" color="' .. beautiful.fg_widget_label ..
|
'<span font="Terminus 8" color="' .. beautiful.fg_widget_label ..
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue