Allow to add group rules to hotkeys_popup default instance
This commit is contained in:
parent
63f78c29a4
commit
c183588ba1
|
@ -0,0 +1,33 @@
|
||||||
|
local hotkeys_popup = require("awful.hotkeys_popup.widget")
|
||||||
|
local fire_rule = { class = { "Firefox" } }
|
||||||
|
for group_name, group_data in pairs({
|
||||||
|
["Firefox: tabs"] = { color = "#009F00", rule_any = fire_rule }
|
||||||
|
}) do
|
||||||
|
hotkeys_popup.add_group_rules(group_name, group_data)
|
||||||
|
end
|
||||||
|
|
||||||
|
local firefox_keys = {
|
||||||
|
|
||||||
|
["Firefox: tabs"] = {{
|
||||||
|
modifiers = { "Mod1" },
|
||||||
|
keys = {
|
||||||
|
["1..9"] = "go to tab"
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
modifiers = { "Ctrl" },
|
||||||
|
keys = {
|
||||||
|
t = "new tab",
|
||||||
|
w = 'close tab',
|
||||||
|
['Tab'] = "next tab"
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
modifiers = { "Ctrl", "Shift" },
|
||||||
|
keys = {
|
||||||
|
['Tab'] = "previous tab"
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
}
|
||||||
|
|
||||||
|
hotkeys_popup.add_hotkeys(firefox_keys)
|
||||||
|
|
||||||
|
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80
|
|
@ -17,7 +17,7 @@ for group_name, group_data in pairs({
|
||||||
["VIM: find"] = { color="#65cF9F", rule_any=vim_rule_any },
|
["VIM: find"] = { color="#65cF9F", rule_any=vim_rule_any },
|
||||||
["VIM: scroll"] = { color="#659FdF", rule_any=vim_rule_any },
|
["VIM: scroll"] = { color="#659FdF", rule_any=vim_rule_any },
|
||||||
}) do
|
}) do
|
||||||
hotkeys_popup.group_rules[group_name] = group_data
|
hotkeys_popup.add_group_rules(group_name, group_data)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -534,7 +534,6 @@ function widget.new(args)
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Add hotkey descriptions for third-party applications.
|
--- Add hotkey descriptions for third-party applications.
|
||||||
-- @tparam table hotkeys Table with bindings,
|
-- @tparam table hotkeys Table with bindings,
|
||||||
-- see `awful.hotkeys_popup.key.vim` as an example.
|
-- see `awful.hotkeys_popup.key.vim` as an example.
|
||||||
|
@ -556,6 +555,13 @@ function widget.new(args)
|
||||||
self:_sort_hotkeys(self._additional_hotkeys)
|
self:_sort_hotkeys(self._additional_hotkeys)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Add hotkey group rules for third-party applications.
|
||||||
|
-- @tparam group hotkeys group name,
|
||||||
|
-- @tparam data rule data for the group
|
||||||
|
-- see `awful.hotkeys_popup.key.vim` as an example.
|
||||||
|
function widget_instance:add_group_rules(group, data)
|
||||||
|
self.group_rules[group] = data
|
||||||
|
end
|
||||||
|
|
||||||
return widget_instance
|
return widget_instance
|
||||||
end
|
end
|
||||||
|
@ -582,6 +588,15 @@ function widget.add_hotkeys(...)
|
||||||
return get_default_widget():add_hotkeys(...)
|
return get_default_widget():add_hotkeys(...)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Add hotkey group rules for third-party applications
|
||||||
|
-- (default widget instance will be used).
|
||||||
|
-- @tparam string hotkeys group name,
|
||||||
|
-- @tparam table rule data for the group
|
||||||
|
-- see `awful.hotkeys_popup.key.vim` as an example.
|
||||||
|
function widget.add_group_rules(...)
|
||||||
|
return get_default_widget():add_group_rules(...)
|
||||||
|
end
|
||||||
|
|
||||||
return widget
|
return widget
|
||||||
|
|
||||||
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80
|
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80
|
||||||
|
|
Loading…
Reference in New Issue