I got the numpad key map by using xev
. So, it may be easy to map numpad to tag switcher as the following:
-- Numpad: [0-9] = [#90, #87-#89, #83-#85, #79-#81]
local np_map = { 87, 88, 89, 83, 84, 85, 79, 80, 81 }
for i = 1, keynumber do
globalkeys = awful.util.table.join(
globalkeys,
awful.key({ modkey }, "#" .. np_map[i],
function ()
local screen = mouse.screen
if tags[screen][i] then
awful.tag.viewonly(tags[screen][i])
end
end),
awful.key({ modkey, "Control" }, "#" .. np_map[i],
function ()
local screen = mouse.screen
if tags[screen][i] then
awful.tag.viewtoggle(tags[screen][i])
end
end),
awful.key({ modkey, "Shift" }, "#" .. np_map[i],
function ()
if client.focus and tags[client.focus.screen][i] then
awful.client.movetotag(tags[client.focus.screen][i])
end
end),
awful.key({ modkey, "Control", "Shift" }, "#" .. np_map[i],
function ()
if client.focus and tags[client.focus.screen][i] then
awful.client.toggletag(tags[client.focus.screen][i])
end
end))
end
I figured it out so I will answer my own question. This might not be the best or most efficient way, but it gets the job done. This question might fit more on stackoverflow since it is more focussed on programming.
I wrote this function, which grabs focus on the first client on screen (except for Conky, the system monitor I use).
-- Grab focus on first client on screen
function grab_focus()
local all_clients = client.get()
for i, c in pairs(all_clients) do
if c:isvisible() and c.class ~= "Conky" then
client.focus = c
end
end
end
I now call this function in rc.lua where the numbered keys are mapped:
-- Bind all key numbers to tags.
...
if tags[screen][i] then
awful.tag.viewonly(tags[screen][i])
grab_focus()
end
Best Answer
Tags are a superset of workspaces. Workspaces are a subset of tags. Each client (window) has an associated list of tags, so you can display it in multiple "workspaces".
From the documentation : "Windows are grouped by tags in awesome. Each window can be tagged with one or more tags. Selecting certain tags displays all windows with these tags."
You have three clients, Firefox, Spotify, and Terminal. Firefox lists tag 1, Spotify lists tag 2, and Terminal lists tags 1 and 2. So when you are on tag 1, Firefox and Terminal are displayed. If you switch to tag 2, Spotify and Terminal are displayed. That's the same thing as workspaces, but you can display a client on multiple tags. You can even display several tags at the same time, so in this case, you'd have Firefox, Spotify and Terminal displayed at the same time.
Hope that helps, have fun with Awesome !