diff --git a/lib/awful/hotkeys_popup/widget.lua b/lib/awful/hotkeys_popup/widget.lua index f8ab93d77..8125ecae3 100644 --- a/lib/awful/hotkeys_popup/widget.lua +++ b/lib/awful/hotkeys_popup/widget.lua @@ -178,7 +178,7 @@ function widget.new(args) }, _additional_hotkeys = {}, _cached_wiboxes = {}, - _cached_awful_keys = nil, + _cached_awful_keys = {}, _colors_counter = {}, _group_list = {}, _widget_settings_loaded = false, @@ -279,10 +279,9 @@ function widget.new(args) function widget_instance:_import_awful_keys() - if self._cached_awful_keys then + if next(self._cached_awful_keys) then return end - self._cached_awful_keys = {} for _, data in pairs(awful.key.hotkeys) do self:_add_hotkey(data.key, data, self._cached_awful_keys) end @@ -308,7 +307,7 @@ function widget.new(args) end - function widget_instance:_create_wibox(s, available_groups) + function widget_instance:_create_wibox(s, available_groups, show_awesome_keys) s = get_screen(s) local wa = s.workarea local height = (self.height < wa.height) and self.height or @@ -323,7 +322,10 @@ function widget.new(args) local max_height_px = height - group_label_height local column_layouts = {} for _, group in ipairs(available_groups) do - local keys = gtable.join(self._cached_awful_keys[group], self._additional_hotkeys[group]) + local keys = gtable.join( + show_awesome_keys and self._cached_awful_keys[group] or nil, + self._additional_hotkeys[group] + ) local joined_descriptions = "" for i, key in ipairs(keys) do joined_descriptions = joined_descriptions .. key.description .. (i~=#keys and "\n" or "") @@ -480,7 +482,13 @@ function widget.new(args) --- Show popup with hotkeys help. -- @tparam[opt] client c Client. -- @tparam[opt] screen s Screen. - function widget_instance:show_help(c, s) + -- @tparam[opt] table show_args Additional arguments. + -- @tparam[opt=true] boolean show_args.show_awesome_keys Show AwesomeWM hotkeys. + -- When set to `false` only app-specific hotkeys will be shown. + function widget_instance:show_help(c, s, show_args) + show_args = show_args or {} + local show_awesome_keys = show_args.show_awesome_keys ~= false + self:_import_awful_keys() self:_load_widget_settings() @@ -508,12 +516,12 @@ function widget.new(args) if not need_match then table.insert(available_groups, group) end end - local joined_groups = join_plus_sort(available_groups) + local joined_groups = join_plus_sort(available_groups)..tostring(show_awesome_keys) if not self._cached_wiboxes[s] then self._cached_wiboxes[s] = {} end if not self._cached_wiboxes[s][joined_groups] then - self._cached_wiboxes[s][joined_groups] = self:_create_wibox(s, available_groups) + self._cached_wiboxes[s][joined_groups] = self:_create_wibox(s, available_groups, show_awesome_keys) end local help_wibox = self._cached_wiboxes[s][joined_groups] help_wibox:show() @@ -575,6 +583,9 @@ end --- Show popup with hotkeys help (default widget instance will be used). -- @tparam[opt] client c Client. -- @tparam[opt] screen s Screen. +-- @tparam[opt] table args Additional arguments. +-- @tparam[opt=true] boolean args.show_awesome_keys Show AwesomeWM hotkeys. +-- When set to `false` only app-specific hotkeys will be shown. function widget.show_help(...) return get_default_widget():show_help(...) end