From d3b682f2b684316580f7a83027c3ea0741389d0a Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Wed, 29 Jul 2015 21:14:40 +0200 Subject: [PATCH] wibox: add __tostring metamethod --- lib/wibox/init.lua | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/wibox/init.lua b/lib/wibox/init.lua index bc5affc7..efbbef96 100644 --- a/lib/wibox/init.lua +++ b/lib/wibox/init.lua @@ -127,6 +127,15 @@ local function new(args) ret:set_bg(args.bg or beautiful.bg_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 ret.draw()