diff --git a/lib/awful/util.lua.in b/lib/awful/util.lua.in index 7074096bd..b320efd99 100644 --- a/lib/awful/util.lua.in +++ b/lib/awful/util.lua.in @@ -237,4 +237,16 @@ function table.join(...) return ret end +--- Check if a table has an item and return its key. +-- @param t The table. +-- @param item The item to look for in values of the table. +-- @return The key were the item is found, or nil if not found. +function table.hasitem(t, item) + for k, v in pairs(t) do + if v == item then + return k + end + end +end + -- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80