You are not logged in.
I'm trying to write a battery widget that changes colors depending on the charge of the battery. I know the function is not perfect, but I'm completely new to lua and pango. Having said that I'm able to get the widget to behave as expected, but there is one small problem. Everytime the widget updates I am getting an error from awesome.
/usr/share/awesome/lib/wibox/widget/textbox lua: 54: bad argument #2 to 'parse_markup' (string expected, got nil)
here is my function
vicious.register(battery_text, vicious.widgets.bat,
function(widget, args)
local color = "#00FF00"
if args[1] == "-" and args[2] > 75 then
color = "#FFFF00"
elseif args[2] <=75 and args[2] > 25 then
color = "#FF8000"
elseif args[2] <= 25 then
color = "#FF0000"
end
battery_text:set_markup('<span color="'.. color ..'"> bat:' ..args[1]..''..args[2].. '%</span>')
end, 10, 'BAT0') I'm assuming my problem is in my set_markup statement, but I'm not sure what it could be since It appears that my widget is working properly. Any help is appreciated.
EDIT: I've change my the battery_text:set_markup line and am still getting the same error
battery_text:set_markup("<span color=\"".. color .. "\"> bat:" ..args[1]..""..args[2].. "%</span>")Last edited by cris9288 (2013-01-07 02:59:08)
Offline
Maybe try something like:
vicious.register(battery_text, function(format, warg)
local args = vicious.widgets.bat(format, warg)
if args[2] < 50 then
args['{color}'] = 'red'
else
args['{color}'] = 'green'
end
return args
end, '<span foreground="${color}">bat: $2%</span>', 10, 'BAT0')That's just how I would do it.
Last edited by ignorant (2013-01-07 02:36:18)
Offline
Ok that works but better. Thanks very much.
Offline