From ec5ec642c37f39da6caa1958c23ddf353e356c10 Mon Sep 17 00:00:00 2001 From: Ari Breitkreuz Date: Tue, 21 Apr 2020 17:44:23 +0200 Subject: [PATCH] Add match_empty option to menubar --- lib/menubar/init.lua | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/menubar/init.lua b/lib/menubar/init.lua index 34877d45..7f350dd9 100644 --- a/lib/menubar/init.lua +++ b/lib/menubar/init.lua @@ -90,6 +90,10 @@ menubar.cache_entries = true -- @tfield[opt=true] boolean show_categories menubar.show_categories = true +--- When false will hide results if the current query is empty +-- @tfield[opt=true] boolean match_empty +menubar.match_empty = true + --- Specifies the geometry of the menubar. This is a table with the keys -- x, y, width and height. Missing values are replaced via the screen's -- geometry. However, missing height is replaced by the font size. @@ -310,7 +314,7 @@ local function menulist_update(scr) end -- Add the applications according to their name and cmdline - for _, v in ipairs(menubar.menu_entries) do + local add_entry = function(v) v.focused = false if not current_category or v.category == current_category then @@ -342,6 +346,14 @@ local function menulist_update(scr) end end + -- Add entries if required + if query ~= "" or menubar.match_empty then + for _, v in ipairs(menubar.menu_entries) do + add_entry(v) + end + end + + local function compare_counts(a, b) if a.prio == b.prio then return a.weight > b.weight