diff --git a/lib/menubar/init.lua b/lib/menubar/init.lua index 34877d457..7f350dd92 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