fixed some issues with the tabbed module; closes #62

This commit is contained in:
Kasper 2021-06-07 23:37:18 +03:00 committed by GitHub
parent 606eecb343
commit c72ff05760
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 5 deletions

View File

@ -50,7 +50,9 @@ end
-- adds a client to a given tabobj -- adds a client to a given tabobj
tabbed.add = function(c, tabobj) tabbed.add = function(c, tabobj)
if c.bling_tabbed then return end if c.bling_tabbed then
tabbed.remove(c)
end
helpers.client.sync(c, tabobj.clients[tabobj.focused_idx]) helpers.client.sync(c, tabobj.clients[tabobj.focused_idx])
tabobj.clients[#tabobj.clients + 1] = c tabobj.clients[#tabobj.clients + 1] = c
tabobj.focused_idx = #tabobj.clients tabobj.focused_idx = #tabobj.clients
@ -91,8 +93,6 @@ end
-- use dmenu to select a client and make it tab in the currently focused tab -- use dmenu to select a client and make it tab in the currently focused tab
tabbed.pick_with_dmenu = function(dmenu_command) tabbed.pick_with_dmenu = function(dmenu_command)
if not client.focus then return end if not client.focus then return end
if not client.focus.bling_tabbed then tabbed.init(client.focus) end
local tabobj = client.focus.bling_tabbed
if not dmenu_command then dmenu_command = "rofi -dmenu -i" end if not dmenu_command then dmenu_command = "rofi -dmenu -i" end
@ -102,7 +102,7 @@ tabbed.pick_with_dmenu = function(dmenu_command)
local list_clients = {} local list_clients = {}
local list_clients_string = "" local list_clients_string = ""
for idx, c in ipairs(t:clients()) do for idx, c in ipairs(t:clients()) do
if not c.bling_tabbed then if c.window ~= client.focus.window then
list_clients[#list_clients + 1] = c list_clients[#list_clients + 1] = c
if #list_clients ~= 1 then if #list_clients ~= 1 then
list_clients_string = list_clients_string .. "\\n" list_clients_string = list_clients_string .. "\\n"
@ -112,12 +112,13 @@ tabbed.pick_with_dmenu = function(dmenu_command)
end end
if #list_clients == 0 then return end if #list_clients == 0 then return end
-- calls the actual dmenu -- calls the actual dmenu
local xprop_cmd = [[ echo -e "]] .. list_clients_string .. [[" | ]] .. dmenu_command .. [[ | awk '{ print $1 }' ]] local xprop_cmd = [[ echo -e "]] .. list_clients_string .. [[" | ]] .. dmenu_command .. [[ | awk '{ print $1 }' ]]
awful.spawn.easy_async_with_shell(xprop_cmd, function(output) awful.spawn.easy_async_with_shell(xprop_cmd, function(output)
for _, c in ipairs(list_clients) do for _, c in ipairs(list_clients) do
if tonumber(c.window) == tonumber(output) then if tonumber(c.window) == tonumber(output) then
if not client.focus.bling_tabbed then tabbed.init(client.focus) end
local tabobj = client.focus.bling_tabbed
tabbed.add(c, tabobj) tabbed.add(c, tabobj)
end end
end end