From ba218af659e798dd2bb4b142c8b186066f565f2e Mon Sep 17 00:00:00 2001 From: Vincent Bernat Date: Sat, 7 Jul 2012 15:17:00 +0200 Subject: [PATCH] widget: display battery level in red if low --- rc/widgets.lua | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/rc/widgets.lua b/rc/widgets.lua index b89159f..dd911b3 100644 --- a/rc/widgets.lua +++ b/rc/widgets.lua @@ -25,8 +25,18 @@ local batwidget = "" if config.hostname == "guybrush" then batwidget = widget({ type = "textbox" }) vicious.register(batwidget, vicious.widgets.bat, - 'BAT: ' .. - '$1 $2%', + function (widget, args) + local color = beautiful.fg_widget_value + local current = args[2] + if current < 10 then + color = beautiful.fg_widget_value_important + end + return string.format( + 'BAT: ' .. + '%s %d%%', args[1], current) + end, 61, "BAT1") end