local wibox = require("wibox") local layout = require("awful.layout") local beautiful = require("beautiful") local screen_widgets = {} -- need one widget per screen local layout_icons = { cornernw = "TT=", cornerne = "=TT", cornersw = "LL=", cornerse = "=LL", fairh = "#_#", fairv = "##H", floating = "><>", magnifier = "=O=", fullscreen = "[*]", spiral = "[]@", dwindle = "[]\\", tile = "[]=", tiletop = "LLL", tilebottom = "TTT", tileleft = "=[]", max = function(s) return string.format("[%s]", #s.clients > 0 and #s.clients or 'M') end, } function update(screen_index) local s = screen[screen_index or 1] local w = screen_widgets[s] local l = layout.get(s) -- create widget if not existing if w == nil then screen_widgets[s] = { widget = wibox.widget.textbox(), layout = l } if beautiful.font_mono then screen_widgets[s].widget.font = beautiful.font_mono end w = screen_widgets[s] --w._layoutbox_tooltip = tooltip {objects = {w}, delay_show = 1} -- skip if no change elseif w.layout == l then return end -- set widget local name = layout.getname(l) --w._layoutbox_tooltip:set_text(name) local wtxt = layout_icons[name] if type(wtxt) == 'function' then wtxt = wtxt(s) elseif wtxt == nil then wtxt = "???" end w.widget:set_text(wtxt) return w.widget end function update_screens() for s, w in pairs(boxes) do if s.valid then update(s) end end end function update_current_tag(t) update(t.screen) end tag.connect_signal("property::selected", update_current_tag) tag.connect_signal("property::layout", update_current_tag) tag.connect_signal("tagged", update_current_tag) -- max tag.connect_signal("untagged", update_current_tag) -- max tag.connect_signal("property::screen", update_screens) return update