mirror of
https://github.com/vincentbernat/i3wm-configuration.git
synced 2025-07-10 18:24:22 +02:00
keydoc: collapse items of the same group together
This commit is contained in:
parent
381812d843
commit
94960c5c2b
3 changed files with 26 additions and 24 deletions
|
@ -42,8 +42,12 @@ awful.key.new = new -- monkey patch
|
||||||
|
|
||||||
-- Turn a key to a string
|
-- Turn a key to a string
|
||||||
local function key2str(key)
|
local function key2str(key)
|
||||||
local sym = key.keysym or key.key
|
local sym = key.key or key.keysym
|
||||||
if sym == "#14" then sym = "#" end
|
local translate = {
|
||||||
|
["#14"] = "#",
|
||||||
|
[" "] = "Space",
|
||||||
|
}
|
||||||
|
sym = translate[sym] or sym
|
||||||
if not key.modifiers or #key.modifiers == 0 then return sym end
|
if not key.modifiers or #key.modifiers == 0 then return sym end
|
||||||
local result = ""
|
local result = ""
|
||||||
local translate = {
|
local translate = {
|
||||||
|
@ -52,9 +56,7 @@ local function key2str(key)
|
||||||
Control = "Ctrl",
|
Control = "Ctrl",
|
||||||
}
|
}
|
||||||
for _, mod in pairs(key.modifiers) do
|
for _, mod in pairs(key.modifiers) do
|
||||||
if translate[mod] then
|
mod = translate[mod] or mod
|
||||||
mod = translate[mod]
|
|
||||||
end
|
|
||||||
result = result .. mod .. " + "
|
result = result .. mod .. " + "
|
||||||
end
|
end
|
||||||
return result .. sym
|
return result .. sym
|
||||||
|
@ -74,7 +76,7 @@ function group(name)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function markup(keys)
|
local function markup(keys)
|
||||||
local result = ""
|
local result = {}
|
||||||
|
|
||||||
-- Compute longest key combination
|
-- Compute longest key combination
|
||||||
local longest = 0
|
local longest = 0
|
||||||
|
@ -88,15 +90,8 @@ local function markup(keys)
|
||||||
for _, key in ipairs(keys) do
|
for _, key in ipairs(keys) do
|
||||||
if doc[key] then
|
if doc[key] then
|
||||||
local help, group = doc[key].help, doc[key].group
|
local help, group = doc[key].help, doc[key].group
|
||||||
if group ~= curgroup then
|
|
||||||
if #result > 0 then result = result .. "\n" end
|
|
||||||
result = result ..
|
|
||||||
'<span weight="bold" color="' .. beautiful.fg_widget_value_important .. '">' ..
|
|
||||||
group .. "</span>\n"
|
|
||||||
curgroup = group
|
|
||||||
end
|
|
||||||
local skey = key2str(key)
|
local skey = key2str(key)
|
||||||
result = result ..
|
result[group] = (result[group] or "") ..
|
||||||
'<span font="DejaVu Sans Mono 10" color="' .. beautiful.fg_widget_clock .. '"> ' ..
|
'<span font="DejaVu Sans Mono 10" color="' .. beautiful.fg_widget_clock .. '"> ' ..
|
||||||
string.format("%" .. (longest - unilen(skey)) .. "s ", "") .. skey ..
|
string.format("%" .. (longest - unilen(skey)) .. "s ", "") .. skey ..
|
||||||
'</span> <span color="' .. beautiful.fg_widget_value .. '">' ..
|
'</span> <span color="' .. beautiful.fg_widget_value .. '">' ..
|
||||||
|
@ -110,14 +105,19 @@ end
|
||||||
-- Display help in a naughty notification
|
-- Display help in a naughty notification
|
||||||
local nid = nil
|
local nid = nil
|
||||||
function display()
|
function display()
|
||||||
local result = markup(capi.root.keys())
|
local strings = awful.util.table.join(
|
||||||
if capi.client.focus then
|
markup(capi.root.keys()),
|
||||||
result = result .. "\n" .. markup(capi.client.focus:keys())
|
capi.client.focus and markup(capi.client.focus:keys()) or {})
|
||||||
end
|
|
||||||
if result then
|
local result = ""
|
||||||
nid = naughty.notify({ text = result,
|
for group, res in pairs(strings) do
|
||||||
replaces_id = nid,
|
if #result > 0 then result = result .. "\n" end
|
||||||
hover_timeout = 0.1,
|
result = result ..
|
||||||
timeout = 30 }).id
|
'<span weight="bold" color="' .. beautiful.fg_widget_value_important .. '">' ..
|
||||||
|
group .. "</span>\n" .. res
|
||||||
end
|
end
|
||||||
|
nid = naughty.notify({ text = result,
|
||||||
|
replaces_id = nid,
|
||||||
|
hover_timeout = 0.1,
|
||||||
|
timeout = 30 }).id
|
||||||
end
|
end
|
||||||
|
|
|
@ -146,6 +146,8 @@ config.keys.client = awful.util.table.join(
|
||||||
awful.key({ modkey }, "Print", screenshot, "Screenshot")
|
awful.key({ modkey }, "Print", screenshot, "Screenshot")
|
||||||
)
|
)
|
||||||
|
|
||||||
|
keydoc.group("Misc")
|
||||||
|
|
||||||
config.mouse.client = awful.util.table.join(
|
config.mouse.client = awful.util.table.join(
|
||||||
awful.button({ }, 1, function (c) client.focus = c; c:raise() end),
|
awful.button({ }, 1, function (c) client.focus = c; c:raise() end),
|
||||||
awful.button({ modkey }, 1, awful.mouse.client.move),
|
awful.button({ modkey }, 1, awful.mouse.client.move),
|
||||||
|
|
|
@ -47,7 +47,7 @@ config.keys.global = awful.util.table.join(
|
||||||
awful.key({ modkey }, "=",
|
awful.key({ modkey }, "=",
|
||||||
function()
|
function()
|
||||||
os.execute(qdbus.next)
|
os.execute(qdbus.next)
|
||||||
end))
|
end, "Change keyboard layout"))
|
||||||
|
|
||||||
-- Run kbdd if not running
|
-- Run kbdd if not running
|
||||||
if os.execute(qdbus.check .. " 2> /dev/null > /dev/null") ~= 0 then
|
if os.execute(qdbus.check .. " 2> /dev/null > /dev/null") ~= 0 then
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue