widget: display battery level in red if low

This commit is contained in:
Vincent Bernat 2012-07-07 15:17:00 +02:00
parent 860cc39867
commit ba218af659

View file

@ -25,8 +25,18 @@ local batwidget = ""
if config.hostname == "guybrush" then if config.hostname == "guybrush" then
batwidget = widget({ type = "textbox" }) batwidget = widget({ type = "textbox" })
vicious.register(batwidget, vicious.widgets.bat, vicious.register(batwidget, vicious.widgets.bat,
'<span font="Terminus 8" color="' .. beautiful.fg_widget_label .. '">BAT: </span>' .. function (widget, args)
'<span font="Terminus 8" color="' .. beautiful.fg_widget_value .. '">$1 $2%</span>', local color = beautiful.fg_widget_value
local current = args[2]
if current < 10 then
color = beautiful.fg_widget_value_important
end
return string.format(
'<span font="Terminus 8" color="' .. beautiful.fg_widget_label ..
'">BAT: </span>' ..
'<span font="Terminus 8" color="' .. color ..
'">%s %d%%</span>', args[1], current)
end,
61, "BAT1") 61, "BAT1")
end end