find_fallback(s, t):
    Looks for a tag on screen 's' and not in 't'.

    This function is meant to be useful for e.g. delete() and
    move_screen() to find a suitable fallback tag.

Signed-off-by: Perry Hargrave <[email protected]>
---
 lib/awful/tag.lua.in |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/lib/awful/tag.lua.in b/lib/awful/tag.lua.in
index 0f9fe27..8465b80 100644
--- a/lib/awful/tag.lua.in
+++ b/lib/awful/tag.lua.in
@@ -46,6 +46,18 @@ function add(name, props)
     return newtag
 end
 
+--- Find a suitable fallback tag.
+-- @param screen The screen number to look for a tag on. [mouse.screen]
+-- @param target A table of tags we consider unacceptable. [{selected()}]
+function find_fallback(screen, invalids)
+    local scr = screen or capi.mouse.screen
+    local t = invalids or {selected(scr)}
+
+    for _, v in pairs(capi.screen[scr]:tags()) do
+        if not util.table.hasitem(t, v) then return v end
+    end
+end
+
 --- Create a set of tags and attach it to a screen.
 -- @param names The tag name, in a table
 -- @param screen The tag screen, or 1 if not set.
-- 
1.7.1


-- 
To unsubscribe, send mail to [email protected].

Reply via email to