diff options
| author | Blista Kanjo | 2022-04-25 13:33:59 -0400 |
|---|---|---|
| committer | Blista Kanjo | 2022-04-25 13:33:59 -0400 |
| commit | a6d578b2a8bb977d0a7b99414bcefe16fbdf15f6 (patch) | |
| tree | 451ced73e4807faffa978ef060000377610163f6 /awesome | |
| parent | 6369c9c43d8ee55e4071af2cdfd6ebdbe9e3bb14 (diff) | |
implementation 2 of proper client swallowing
Diffstat (limited to 'awesome')
| -rw-r--r-- | awesome/rc.lua | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/awesome/rc.lua b/awesome/rc.lua index 04a91e7..bae502c 100644 --- a/awesome/rc.lua +++ b/awesome/rc.lua @@ -665,6 +665,7 @@ awful.spawn.easy_async_with_shell("/home/kylert/.config/awesome/autorun.sh") -- Client Swallowing Function table_is_swallowed = { "Alacritty" } +table_minimize_parent = { "mpv" } table_cannot_swallow = { "xev" } function is_in_Table(table, element) @@ -684,6 +685,10 @@ function can_swallow(class) return not is_in_Table(table_cannot_swallow, class) end +function is_parent_minimized(class) + return is_in_Table(table_minimize_parent, class) +end + function copy_size(c, parent_client) if (not c or not parent_client) then return @@ -703,14 +708,14 @@ function check_resize_client(c) end function get_parent_pid(child_ppid, callback) - local ppid_cmd = string.format("ps -o ppid= -p %s", child_ppid) + local ppid_cmd = string.format("pstree -ps %s", child_ppid) awful.spawn.easy_async(ppid_cmd, function(stdout, stderr, reason, exit_code) -- primitive error checking if stderr and stderr ~= "" then callback(stderr) return end - local ppid = stdout:gsub(" ", ""):gsub("\n", "") + local ppid = stdout callback(nil, ppid) end) end @@ -728,20 +733,18 @@ client.connect_signal("manage", function(c) return end parent_pid = ppid - get_parent_pid(parent_pid, function(err, gppid) - if err then - error(err) - return - end - grand_parent_pid = gppid - if parent_client and (parent_pid:find('^' .. parent_client.pid) or grand_parent_pid:find('^' .. parent_client.pid)) and is_to_be_swallowed(parent_client) and can_swallow(c.class) then - -- c.floating=true + if parent_client and (parent_pid:find("("..parent_client.pid..")")) and is_to_be_swallowed(parent_client) and can_swallow(c.class) then + if is_parent_minimized(c.class) then + parent_client.child_resize=c parent_client.minimized = true c:connect_signal("unmanage", function() parent_client.minimized = false end) + copy_size(c, parent_client) + else parent_client.child_resize=c + c.floating=true copy_size(c, parent_client) end - end) + end end) end) |
