diff options
author | Timmy Keller <tjk@tjkeller.xyz> | 2024-09-28 22:47:28 -0500 |
---|---|---|
committer | Timmy Keller <tjk@tjkeller.xyz> | 2024-09-28 22:47:28 -0500 |
commit | 9d7c46cb29293c5f553f1204c25d9afa7506f8c2 (patch) | |
tree | 34f95a3eae0c0adacd3d766c4478195f0c8d32d3 /awesome/widgets/classiclayoutbox.lua | |
parent | ad8a5145c3db84ae34d2f475eff35427640ba64b (diff) | |
parent | d1f9ee5eced0c273de6c598f88ddb0f7b4e54230 (diff) | |
download | dotconfig-9d7c46cb29293c5f553f1204c25d9afa7506f8c2.tar.xz dotconfig-9d7c46cb29293c5f553f1204c25d9afa7506f8c2.zip |
Merge branch 'master' of localgit:dotconfig
Diffstat (limited to 'awesome/widgets/classiclayoutbox.lua')
-rw-r--r-- | awesome/widgets/classiclayoutbox.lua | 92 |
1 files changed, 45 insertions, 47 deletions
diff --git a/awesome/widgets/classiclayoutbox.lua b/awesome/widgets/classiclayoutbox.lua index ac08671..818dc0f 100644 --- a/awesome/widgets/classiclayoutbox.lua +++ b/awesome/widgets/classiclayoutbox.lua @@ -33,7 +33,7 @@ local layout_icons = { } local function get_screen(s) -return s and capi.screen[s] + return s and capi.screen[s] end local layoutbox = { mt = {} } @@ -41,24 +41,25 @@ local layoutbox = { mt = {} } local boxes = nil local function update(w, screen) -screen = get_screen(screen) -local name = layout.getname(layout.get(screen)) -w._layoutbox_tooltip:set_text(name or "[no name]") + screen = get_screen(screen) + local name = layout.getname(layout.get(screen)) + w._layoutbox_tooltip:set_text(name or "[no name]") if name == "max" and #screen.clients > 0 then - w.textbox.text = "[" .. #screen.clients .. "]" + w.textbox.text = " [" .. #screen.clients .. "] " -- TODO manage / unmanage signal return end - w.textbox.text = layout_icons[name] + w.textbox.text = layout_icons[name] + w.textbox.text = " " .. w.textbox.text .. " " end local function update_from_tag(t) -local screen = get_screen(t.screen) -local w = boxes[screen] -if w then - update(w, screen) -end + local screen = get_screen(t.screen) + local w = boxes[screen] + if w then + update(w, screen) + end end --- Create a layoutbox widget. It draws a picture with the current layout @@ -66,48 +67,45 @@ end -- @param screen The screen number that the layout will be represented for. -- @return An imagebox widget configured as a layoutbox. function layoutbox.new(screen) -screen = get_screen(screen or 1) - --- Do we already have the update callbacks registered? -if boxes == nil then - boxes = setmetatable({}, { __mode = "kv" }) - capi.tag.connect_signal("property::selected", update_from_tag) - capi.tag.connect_signal("property::layout", update_from_tag) - capi.tag.connect_signal("property::screen", function() - for s, w in pairs(boxes) do - if s.valid then - update(w, s) + screen = get_screen(screen or 1) + + -- Do we already have the update callbacks registered? + if boxes == nil then + boxes = setmetatable({}, { __mode = "kv" }) + capi.tag.connect_signal("property::selected", update_from_tag) + capi.tag.connect_signal("property::layout", update_from_tag) + capi.tag.connect_signal("property::screen", function() + for s, w in pairs(boxes) do + if s.valid then + update(w, s) + end end - end - end) - layoutbox.boxes = boxes -end + end) + layoutbox.boxes = boxes + end --- Do we already have a layoutbox for this screen? -local w = boxes[screen] -if not w then - w = wibox.widget { - { - id = "textbox", - widget = wibox.widget.textbox - }, - layout = wibox.layout.fixed.horizontal - } - - w._layoutbox_tooltip = tooltip {objects = {w}, delay_show = 1} - - update(w, screen) - boxes[screen] = w -end + -- Do we already have a layoutbox for this screen? + local w = boxes[screen] + if not w then + w = wibox.widget { + { + id = "textbox", + widget = wibox.widget.textbox + }, + layout = wibox.layout.fixed.horizontal + } + + w._layoutbox_tooltip = tooltip {objects = {w}, delay_show = 1} + + update(w, screen) + boxes[screen] = w + end -return w + return w end function layoutbox.mt:__call(...) -return layoutbox.new(...) + return layoutbox.new(...) end return setmetatable(layoutbox, layoutbox.mt) - --- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80 - |