Fix mod4+[1-9] in default rc.lua
The old code had flaws: * If the tag chnaged screen, the code was unstable. * If awful.tag.del was used, then it displayed an error * If tags were added later, the keyboard shortcut were unavailable
This commit is contained in:
parent
d5a3669e96
commit
e7912fc2a8
|
@ -292,41 +292,39 @@ clientkeys = awful.util.table.join(
|
||||||
end)
|
end)
|
||||||
)
|
)
|
||||||
|
|
||||||
-- Compute the maximum number of digit we need, limited to 9
|
|
||||||
keynumber = 0
|
|
||||||
for s = 1, screen.count() do
|
|
||||||
keynumber = math.min(9, math.max(#tags[s], keynumber))
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Bind all key numbers to tags.
|
-- Bind all key numbers to tags.
|
||||||
-- Be careful: we use keycodes to make it works on any keyboard layout.
|
-- Be careful: we use keycodes to make it works on any keyboard layout.
|
||||||
-- This should map on the top row of your keyboard, usually 1 to 9.
|
-- This should map on the top row of your keyboard, usually 1 to 9.
|
||||||
for i = 1, keynumber do
|
for i = 1, 9 do
|
||||||
globalkeys = awful.util.table.join(globalkeys,
|
globalkeys = awful.util.table.join(globalkeys,
|
||||||
awful.key({ modkey }, "#" .. i + 9,
|
awful.key({ modkey }, "#" .. i + 9,
|
||||||
function ()
|
function ()
|
||||||
local screen = mouse.screen
|
local screen = mouse.screen
|
||||||
if tags[screen][i] then
|
local tag = awful.tag.gettags(screen)[i]
|
||||||
awful.tag.viewonly(tags[screen][i])
|
if tag then
|
||||||
|
awful.tag.viewonly(tag)
|
||||||
end
|
end
|
||||||
end),
|
end),
|
||||||
awful.key({ modkey, "Control" }, "#" .. i + 9,
|
awful.key({ modkey, "Control" }, "#" .. i + 9,
|
||||||
function ()
|
function ()
|
||||||
local screen = mouse.screen
|
local screen = mouse.screen
|
||||||
if tags[screen][i] then
|
local tag = awful.tag.gettags(screen)[i]
|
||||||
awful.tag.viewtoggle(tags[screen][i])
|
if tag then
|
||||||
|
awful.tag.viewtoggle(tag)
|
||||||
end
|
end
|
||||||
end),
|
end),
|
||||||
awful.key({ modkey, "Shift" }, "#" .. i + 9,
|
awful.key({ modkey, "Shift" }, "#" .. i + 9,
|
||||||
function ()
|
function ()
|
||||||
if client.focus and tags[client.focus.screen][i] then
|
local tag = awful.tag.gettags(client.focus.screen)[i]
|
||||||
awful.client.movetotag(tags[client.focus.screen][i])
|
if client.focus and tag then
|
||||||
end
|
awful.client.movetotag(tag)
|
||||||
|
end
|
||||||
end),
|
end),
|
||||||
awful.key({ modkey, "Control", "Shift" }, "#" .. i + 9,
|
awful.key({ modkey, "Control", "Shift" }, "#" .. i + 9,
|
||||||
function ()
|
function ()
|
||||||
if client.focus and tags[client.focus.screen][i] then
|
local tag = awful.tag.gettags(client.focus.screen)[i]
|
||||||
awful.client.toggletag(tags[client.focus.screen][i])
|
if client.focus and tag then
|
||||||
|
awful.client.toggletag(tag)
|
||||||
end
|
end
|
||||||
end))
|
end))
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue