summaryrefslogtreecommitdiff
path: root/func/tagnames.lua
diff options
context:
space:
mode:
authorTim Keller <tjk@tjkeller.xyz>2024-10-18 21:49:17 -0500
committerTim Keller <tjk@tjkeller.xyz>2024-10-18 21:49:17 -0500
commit923eb46350b1102749eb05cd2120c96cc6a715d0 (patch)
tree811da20b4195d4b5c65c8ac0090982a4a23f6a7d /func/tagnames.lua
downloadawesome-923eb46350b1102749eb05cd2120c96cc6a715d0.tar.xz
awesome-923eb46350b1102749eb05cd2120c96cc6a715d0.zip
initial commit
Diffstat (limited to 'func/tagnames.lua')
-rw-r--r--func/tagnames.lua51
1 files changed, 51 insertions, 0 deletions
diff --git a/func/tagnames.lua b/func/tagnames.lua
new file mode 100644
index 0000000..fcd01a4
--- /dev/null
+++ b/func/tagnames.lua
@@ -0,0 +1,51 @@
+--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
+
+ -- 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
+ end
+ end
+ end
+end
+
+function nametagsc(c)
+ nametags(c.screen)
+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)
+
+--awful.screen.connect_for_each_screen(nametags)