wibox: add __tostring metamethod

This commit is contained in:
Daniel Hahler 2015-07-29 21:14:40 +02:00
parent 430e8664be
commit d3b682f2b6
1 changed files with 9 additions and 0 deletions

View File

@ -127,6 +127,15 @@ local function new(args)
ret:set_bg(args.bg or beautiful.bg_normal) ret:set_bg(args.bg or beautiful.bg_normal)
ret:set_fg(args.fg or beautiful.fg_normal) ret:set_fg(args.fg or beautiful.fg_normal)
-- Add __tostring method to metatable.
local mt = {}
local orig_string = tostring(ret)
mt.__tostring = function(o)
return string.format("wibox: %s (%s)",
tostring(ret._drawable), orig_string)
end
ret = setmetatable(ret, mt)
-- Make sure the wibox is drawn at least once -- Make sure the wibox is drawn at least once
ret.draw() ret.draw()