Merge pull request #594 from blueyed/pr-552

Add an optional filter to `awful.menu.clients`
This commit is contained in:
Daniel Hahler 2015-12-12 21:19:32 +01:00
commit f7fcee76df
1 changed files with 10 additions and 7 deletions

View File

@ -15,6 +15,7 @@ local util = require("awful.util")
local spawn = require("awful.spawn")
local tags = require("awful.tag")
local keygrabber = require("awful.keygrabber")
local client_iterate = require("awful.client").iterate
local beautiful = require("beautiful")
local dpi = require("beautiful").xresources.apply_dpi
local object = require("gears.object")
@ -458,15 +459,17 @@ end
--------------------------------------------------------------------------------
--- Build a popup menu with running clients and shows it.
-- @param args Menu table, see new() function for more informations
-- @param item_args Table that will be merged into each item, see new() for more
-- informations.
--- Build a popup menu with running clients and show it.
-- @tparam[opt] table args Menu table, see `new()` for more information.
-- @tparam[opt] table item_args Table that will be merged into each item, see
-- `new()` for more information.
-- @tparam[opt] func filter A function taking a client as an argument and
-- returning `true` or `false` to indicate whether the client should be
-- included in the menu.
-- @return The menu.
function menu.clients(args, item_args)
local cls = capi.client.get()
function menu.clients(args, item_args, filter)
local cls_t = {}
for k, c in pairs(cls) do
for c in client_iterate(filter or function() return true end) do
cls_t[#cls_t + 1] = {
c.name or "",
function ()