From 1f6cd7374c9cfa38e212db5c877ca617be643956 Mon Sep 17 00:00:00 2001 From: Nooo37 Date: Sun, 20 Dec 2020 20:38:13 +0100 Subject: [PATCH] added dmenu picker for tabbed --- README.md | 2 +- module/tabbed.lua | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index e029ad5..c0d1367 100644 --- a/README.md +++ b/README.md @@ -120,7 +120,7 @@ gif by me :) - [x] Add another cool tabbar style (we need more styles) - [x] Make the mstab layout compatible with vertical tabbars (left and right) - [x] Add option to mstab layout to not shrink windows down when they are in the tabbed pane and unfocused (for example for people using transparent terminals) -- [ ] Keyboard based option to add windows to a tabbing object +- [x] Keyboard based option to add windows to a tabbing object All naming credit goes to javacafe. diff --git a/module/tabbed.lua b/module/tabbed.lua index 40844e9..dfc0ee5 100644 --- a/module/tabbed.lua +++ b/module/tabbed.lua @@ -89,6 +89,42 @@ tabbed.pick = function() end) end +-- use dmenu to select a client and make it tab in the currently focused tab +tabbed.pick_with_dmenu = function(dmenu_command) + 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 + + -- get all clients from the current tag + -- ignores the case where multiple tags are selected + local t = awful.screen.focused().selected_tag + local list_clients = {} + local list_clients_string = "" + for idx, c in ipairs(t:clients()) do + if not c.bling_tabbed then + list_clients[#list_clients + 1] = c + if #list_clients ~= 1 then + list_clients_string = list_clients_string .. "\\n" + end + list_clients_string = list_clients_string .. tostring(c.window) .. " " .. c.name + end + end + + if #list_clients == 0 then return end + + -- calls the actual dmenu + local xprop_cmd = [[ echo -e "]] .. list_clients_string .. [[" | ]] .. dmenu_command .. [[ | awk '{ print $1 }' ]] + awful.spawn.easy_async_with_shell(xprop_cmd, function(output) + for _, c in ipairs(list_clients) do + if tonumber(c.window) == tonumber(output) then + tabbed.add(c, tabobj) + end + end + end) +end + -- update everything about one tab object tabbed.update = function(tabobj) local currently_focused_c = tabobj.clients[tabobj.focused_idx]