mirror of
https://github.com/vincentbernat/i3wm-configuration.git
synced 2025-07-01 13:54:22 +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
|
||||
local batwidget = ""
|
||||
if config.hostname == "guybrush" then
|
||||
local batlastwarn = nil
|
||||
batwidget = widget({ type = "textbox" })
|
||||
vicious.register(batwidget, vicious.widgets.bat,
|
||||
function (widget, args)
|
||||
local color = beautiful.fg_widget_value
|
||||
local current = args[2]
|
||||
if current < 10 then
|
||||
if current < 10 and args[1] == "-" then
|
||||
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
|
||||
return string.format(
|
||||
'<span font="Terminus 8" color="' .. beautiful.fg_widget_label ..
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue