Merge pull request #594 from blueyed/pr-552
Add an optional filter to `awful.menu.clients`
This commit is contained in:
commit
f7fcee76df
|
@ -15,6 +15,7 @@ local util = require("awful.util")
|
||||||
local spawn = require("awful.spawn")
|
local spawn = require("awful.spawn")
|
||||||
local tags = require("awful.tag")
|
local tags = require("awful.tag")
|
||||||
local keygrabber = require("awful.keygrabber")
|
local keygrabber = require("awful.keygrabber")
|
||||||
|
local client_iterate = require("awful.client").iterate
|
||||||
local beautiful = require("beautiful")
|
local beautiful = require("beautiful")
|
||||||
local dpi = require("beautiful").xresources.apply_dpi
|
local dpi = require("beautiful").xresources.apply_dpi
|
||||||
local object = require("gears.object")
|
local object = require("gears.object")
|
||||||
|
@ -458,15 +459,17 @@ end
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
--- Build a popup menu with running clients and shows it.
|
--- Build a popup menu with running clients and show it.
|
||||||
-- @param args Menu table, see new() function for more informations
|
-- @tparam[opt] table args Menu table, see `new()` for more information.
|
||||||
-- @param item_args Table that will be merged into each item, see new() for more
|
-- @tparam[opt] table item_args Table that will be merged into each item, see
|
||||||
-- informations.
|
-- `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.
|
-- @return The menu.
|
||||||
function menu.clients(args, item_args)
|
function menu.clients(args, item_args, filter)
|
||||||
local cls = capi.client.get()
|
|
||||||
local cls_t = {}
|
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] = {
|
cls_t[#cls_t + 1] = {
|
||||||
c.name or "",
|
c.name or "",
|
||||||
function ()
|
function ()
|
||||||
|
|
Loading…
Reference in New Issue