diff options
Diffstat (limited to 'func/tagnames.lua')
-rw-r--r-- | func/tagnames.lua | 81 |
1 files changed, 39 insertions, 42 deletions
diff --git a/func/tagnames.lua b/func/tagnames.lua index fcd01a4..75284ed 100644 --- a/func/tagnames.lua +++ b/func/tagnames.lua @@ -1,51 +1,48 @@ ---TODO find out why it doesnt work at start ---local awful = require("awful") - -function nametags(s) - local tags = s.tags - for _, tag in ipairs(tags) do - -- set tag basename - if tag.basename == nil then - tag.basename = tag.name - end +local nametag_format = "%s: %s" - -- check if tag has any clients. if not, use basename - if next(tag:clients()) == nil then - tag.name = tag.basename - else - -- loop over all screen clients (ordered top to bottom) - local hastag = nil - for _, c in ipairs(s.clients) do - -- test if client in on the tag - for _, ctag in ipairs(c:tags()) do - if ctag == tag then - hastag = c - break - end - end - -- if it does, this will be the tag name. so break - if hastag ~= nil then - break - end - end - -- set tag name - -- there should always be a tag since we checked above so if there isnt then there is clearly a problem - --TODO remove this if statement - if hastag then - tag.name = tag.basename .. ": " .. hastag.class +function nametag(t, name) + -- set tag basename + if t.basename == nil then + t.basename = t.name + end + + if name == nil then + t.name = t.basename + return + end + + t.name = string.format(nametag_format, t.basename, name) +end + +function nametagc_t(t, c) + local cs = t.screen:get_all_clients(true) + if c then + table.insert(cs, c) + end + + for _, c in ipairs(cs) do + for _, ct in ipairs(c:tags()) do + if ct == t then + nametag(t, c.class) + return end end end + nametag(t) end -function nametagsc(c) - nametags(c.screen) +-- without client +function nametagc_t_u(t) + nametagc_t(t) end -client.connect_signal("manage", nametagsc) -client.connect_signal("swapped", nametagsc) -client.connect_signal("tagged", nametagsc) -client.connect_signal("unmanage", nametagsc) -client.connect_signal("untagged", nametagsc) +function nametagc_c(c) + for _, ct in ipairs(c:tags()) do + nametagc_t(ct, c) + end +end ---awful.screen.connect_for_each_screen(nametags) +tag.connect_signal("tagged", nametagc_t) +tag.connect_signal("untagged", nametagc_t_u) +client.connect_signal("raised", nametagc_c) +client.connect_signal("property::class", nametagc_c) |