add tag support for 10 to 20

This commit is contained in:
Roland Schneider 2022-01-30 09:21:48 +01:00
parent 06fbcaee7c
commit 656951981e

151
rc.lua
View File

@ -42,18 +42,31 @@ local switcher = require("awesome-switcher")
local KEY_ALT = "Mod1" local KEY_ALT = "Mod1"
local tag1 = "1:idea" local tag1 = "1"
local tag2 = "2:brow" local tag2 = "2"
local tag3 = "3:term" local tag3 = "3"
local tag4 = "4:code" local tag4 = "4"
local tag5 = "5:zoom" local tag5 = "5"
local tag6 = "6:chat" local tag6 = "6"
local tag7 = "7:pass" local tag7 = "7"
local tag8 = "8" local tag8 = "8"
local tag9 = "9" local tag9 = "9"
local tag10 = "10"
local tag11 = "11"
local tag12 = "12"
local tag13 = "13"
local tag14 = "14"
local tag15 = "15"
local tag16 = "16"
local tag17 = "17"
local tag18 = "18"
local tag19 = "19"
local tag20 = "20"
local tags = { local tags = {
tag1,tag2,tag3,tag4,tag5,tag6,tag7,tag8,tag9 tag1,tag2,tag3,tag4,tag5,tag6,tag7,tag8,tag9,tag10,
tag11,tag12,tag13,tag14,tag15,tag16,tag17,tag18,tag19,tag20
} }
local wibar_font="Deja Vu Sans Mono 14" local wibar_font="Deja Vu Sans Mono 14"
@ -292,12 +305,14 @@ local function set_wallpaper(s)
end end
end end
-- get count of elements in table
function tablelength(T) function tablelength(T)
local count = 0 local count = 0
for _ in pairs(T) do count = count + 1 end for _ in pairs(T) do count = count + 1 end
return count return count
end end
-- return all client from selected tag
local function getAllClient() local function getAllClient()
local focusedScreen = awful.screen.focused () local focusedScreen = awful.screen.focused ()
local t = focusedScreen.selected_tag local t = focusedScreen.selected_tag
@ -306,6 +321,7 @@ local function getAllClient()
end end
-- restore the given client
local function restoreClient(currentClient) local function restoreClient(currentClient)
currentClient.minimized = false currentClient.minimized = false
currentClient.maximized = false currentClient.maximized = false
@ -320,12 +336,14 @@ local function restoreAll()
end end
end end
-- minimize the given client
local function minimizeClient(currentClient) local function minimizeClient(currentClient)
currentClient.minimized = true currentClient.minimized = true
currentClient.maximized = false currentClient.maximized = false
currentClient.fullscreen = false currentClient.fullscreen = false
end end
-- minimize all client
local function minimizeAll() local function minimizeAll()
local clientsOnTag = getAllClient() local clientsOnTag = getAllClient()
for k, currentClient in pairs(clientsOnTag) do for k, currentClient in pairs(clientsOnTag) do
@ -363,6 +381,27 @@ local function normalizeClients()
end end
end end
local function move_tag_to_focused_screen(tagName)
-- For all screens: find tag by name
print("looking for tag " .. tagName)
local tagByName = awful.tag.find_by_name(nil, tagName)
if tag then
print("tag found with name" .. tagName)
local screenFocused = awful.screen.focused()
tagByName.screen=screenFocused
tagByName:view_only()
end
end
local function move_client_to_tag(tagName)
if client.focus then
local tag = awful.tag.find_by_name(nil, tagName)
if tag then
client.focus:move_to_tag(tag)
end
end
end
-- Re-set wallpaper when a screen's geometry changes (e.g. different resolution) -- Re-set wallpaper when a screen's geometry changes (e.g. different resolution)
screen.connect_signal("property::geometry", set_wallpaper) screen.connect_signal("property::geometry", set_wallpaper)
@ -644,31 +683,12 @@ clientkeys = gears.table.join(
{description = "(un)maximize horizontally", group = "client"}) {description = "(un)maximize horizontally", group = "client"})
) )
local function move_tag_to_focused_screen(tagName)
-- For all screens: find tag by name
print("looking for tag " .. tagName)
local tagByName = awful.tag.find_by_name(nil, tagName)
if tag then
print("tag found with name" .. tagName)
local screenFocused = awful.screen.focused()
tagByName.screen=screenFocused
tagByName:view_only()
end
end
local function move_client_to_tag(tagName)
if client.focus then
local tag = awful.tag.find_by_name(nil, tagName)
if tag then
client.focus:move_to_tag(tag)
end
end
end
-- Bind all key numbers to tags. -- Bind all key numbers to tags.
-- Be careful: we use keycodes to make it work on any keyboard layout. -- Be careful: we use keycodes to make it work 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, 9 do for i = 1, 10 do
globalkeys = gears.table.join(globalkeys, globalkeys = gears.table.join(globalkeys,
-- View tag only. -- View tag only.
-- mod + i -> show tag -- mod + i -> show tag
@ -687,7 +707,7 @@ for i = 1, 9 do
function () function ()
selectClientIdx(i) selectClientIdx(i)
end, end,
{description = "view tag #"..i, group = "tag"}), {description = "select client in active tag #"..i, group = "client"}),
-- Toggle tag display. -- Toggle tag display.
-- --
@ -713,19 +733,78 @@ for i = 1, 9 do
-- end -- end
move_client_to_tag(tags[i]) move_client_to_tag(tags[i])
end, end,
{description = "move focused client to tag #"..i, group = "tag"}), {description = "move focused client to tag #"..i, group = "tag"})
-- Toggle tag on focused client. -- Toggle tag on focused client.
-- mod + ctrl + shift +i -> toggle focused client on tag -- mod + ctrl + shift +i -> toggle focused client on tag
awful.key({ modkey, "Control", "Shift" }, "#" .. i + 9, --awful.key({ modkey, "Control", "Shift" }, "#" .. i + 9,
-- function ()
-- if client.focus then
-- local tag = client.focus.screen.tags[i]
-- if tag then
-- client.focus:toggle_tag(tag)
-- end
-- end
-- end,
-- {description = "toggle focused client on tag #" .. i, group = "tag"})
)
end
-- Numpad: [0-9] = [#90, #87-#89, #83-#85, #79-#81]
local numpadMap = { 87, 88, 89, 83, 84, 85, 79, 80, 81, 90 }
-- tags 11-20
for i = 1, 10 do
globalkeys = gears.table.join(globalkeys,
-- View tag only.
-- mod + i -> show tag
awful.key({ modkey }, "#" .. numpadMap[i],
function () function ()
if client.focus then -- local screen = awful.screen.focused()
local tag = client.focus.screen.tags[i] -- local tag = screen.tags[i]
-- if tag then
-- tag:view_only()
-- end
move_tag_to_focused_screen(tags[10+ i])
end,
{description = "view tag #"..(10+i), group = "tag"}),
-- Toggle tag display.
--
-- mod + ctrl + i -> show/hide tag
awful.key({ modkey, "Control" }, "#" .. numpadMap[i],
function ()
local screen = awful.screen.focused()
local tag = screen.tags[10+i]
if tag then if tag then
client.focus:toggle_tag(tag) awful.tag.viewtoggle(tag)
end
end end
end, end,
{description = "toggle focused client on tag #" .. i, group = "tag"}) {description = "toggle tag #" .. (10+i), group = "tag"}),
-- Move client to tag.
-- mod + shift + i -> move client to tag
awful.key({ modkey, "Shift" }, "#" .. numpadMap[i],
function ()
-- if client.focus then
-- local tag = client.focus.screen.tags[i]
-- if tag then
-- client.focus:move_to_tag(tag)
-- end
-- end
move_client_to_tag(tags[10+i])
end,
{description = "move focused client to tag #"..(10+i), group = "tag"})
-- Toggle tag on focused client.
-- mod + ctrl + shift +i -> toggle focused client on tag
-- awful.key({ modkey, "Control", "Shift" }, "#" .. np_map[i],
-- function ()
-- if client.focus then
-- local tag = client.focus.screen.tags[i]
-- if tag then
-- client.focus:toggle_tag(tag)
-- end
-- end
-- end,
-- {description = "toggle focused client on tag #" .. i, group = "tag"})
) )
end end