awful.tag.getidx(query_tag)
looks for 'query_tag' or selected() in the table of tags in the
table screen[s]:tags() and returns the index or zero if not found
---
lib/awful/tag.lua.in | 18 ++++++++++++++++++
1 files changed, 18 insertions(+), 0 deletions(-)
diff --git a/lib/awful/tag.lua.in b/lib/awful/tag.lua.in
index c8b54ce..749a76f 100644
--- a/lib/awful/tag.lua.in
+++ b/lib/awful/tag.lua.in
@@ -319,6 +319,24 @@ function viewidx(i, screen)
capi.screen[screen]:emit_signal("tag::history::update")
end
+--- Get a tags index in the screen[]:tags() table
+-- @param query_tag Optional tag to find, [selected()]
+-- @return The index of the tag, 0 if not found
+function getidx(query_tag)
+ local query_tag = query_tag or selected()
+
+ -- return a number to avoid any numerical operations with nil
+ if query_tag == nil then return 0 end
+
+ -- iterate over tags on this screen
+ for i, t in ipairs(capi.screen[query_tag.screen]:tags()) do
+ if t == query_tag then
+ return i
+ end
+ end
+
+end
+
--- View next tag. This is the same as tag.viewidx(1).
-- @param screen The screen number.
function viewnext(screen)
--
1.7.0.1
--
To unsubscribe, send mail to [email protected].