diff --git a/lib/awful/client.lua.in b/lib/awful/client.lua.in index b63a6465..fa605663 100644 --- a/lib/awful/client.lua.in +++ b/lib/awful/client.lua.in @@ -862,6 +862,30 @@ function property.set(c, prop, value) c:emit_signal("property::" .. prop) end +--- +-- Returns an iterator to cycle through, starting from the client in focus or +-- the given index, all clients that match a given criteria. +-- @param filter a function that returns true to indicate a positive match +-- @param start what index to start iterating from. Defaults to using the +-- index of the currently focused client. +-- @param s which screen to use. nil means all screens. +-- @usage e.g.: un-minimize all urxvt instances +--

+-- local urxvt = function (c)
+-- return awful.rules.match(c, {class = "URxvt"})
+-- end
+--
+-- for c in awful.client.cycle(urxvt) do
+-- c.minimized = false
+-- end
+--

+function cycle(filter, start, s) + local clients = capi.client.get(s) + local focused = capi.client.focus + local start = start or util.table.hasitem(clients, focused) + return util.table.cycle(clients, filter, start) +end + -- Register standards signals capi.client.add_signal("focus", focus.history.add) capi.client.add_signal("unmanage", focus.history.delete)