From 06fbcaee7c8a19de6c83ad02348acec73d1632fc Mon Sep 17 00:00:00 2001 From: Roland Schneider Date: Sat, 29 Jan 2022 23:24:25 +0100 Subject: [PATCH] restore all, select client by idx --- rc.lua | 50 +++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 41 insertions(+), 9 deletions(-) diff --git a/rc.lua b/rc.lua index a774020..60d6e27 100644 --- a/rc.lua +++ b/rc.lua @@ -306,32 +306,58 @@ local function getAllClient() end +local function restoreClient(currentClient) + currentClient.minimized = false + currentClient.maximized = false + currentClient.fullscreen = false +end + -- make all client minimized=false,maximized=false,fullscreen=false local function restoreAll() local clientsOnTag = getAllClient() for k, currentClient in pairs(clientsOnTag) do - currentClient.minimized = false - currentClient.maximized = false - currentClient.fullscreen = false + restoreClient(currentClient) + end +end + +local function minimizeClient(currentClient) + currentClient.minimized = true + currentClient.maximized = false + currentClient.fullscreen = false +end + +local function minimizeAll() + local clientsOnTag = getAllClient() + for k, currentClient in pairs(clientsOnTag) do + minimizeClient(currentClient) + end +end + +-- make all client minimized=false,maximized=false,fullscreen=false +local function selectClientIdx(idx) + local clientsOnTag = getAllClient() + local clientCount = tablelength(clientsOnTag) + minimizeAll() + if ( clientCount >= idx ) then + local clientToFocus = clientsOnTag[idx]; + client.focus = clientToFocus + clientToFocus:raise() + restoreClient(clientToFocus) end end -- only the focused client will be opened, all other client minimized -local function normalizeClients(idx) +local function normalizeClients() local focusedScreen = awful.screen.focused () local focusedClient = client.focus local t = focusedScreen.selected_tag - print ( 'tag' .. tostring(t)) local clientsOnTag = t:clients() - print('focused is'..tostring(focusedClient)) for k, currentClient in pairs(clientsOnTag) do currentClient.maximized = false if currentClient == focusedClient then - print('focused found'..tostring(k)) currentClient.minimized = false else - print('minimize client'..tostring(currentClient)) currentClient.minimized = true; end end @@ -449,6 +475,12 @@ globalkeys = gears.table.join( end, {description = "focus previous by index", group = "client"} ), + awful.key({ modkey, }, "o", + function () + restoreAll() + end, + {description = "restore all", group = "client"} + ), awful.key({ modkey, }, "u", function () restoreAll() @@ -653,7 +685,7 @@ for i = 1, 9 do awful.key({ modkey, KEY_ALT }, "#" .. i + 9, function () - move_tag_to_focused_screen(tags[i]) + selectClientIdx(i) end, {description = "view tag #"..i, group = "tag"}),