From 8b6d5df28a1766c16f7c67784d059ef1042443b9 Mon Sep 17 00:00:00 2001 From: zachir Date: Wed, 15 Mar 2023 01:36:29 -0500 Subject: fix window swallowing in awesome (although it's still kinda jank) --- awesome/rc.lua | 112 ++++++++++++++++++++++++++++++--------------------------- 1 file changed, 60 insertions(+), 52 deletions(-) (limited to 'awesome') diff --git a/awesome/rc.lua b/awesome/rc.lua index dad67ff..d4dc3c9 100644 --- a/awesome/rc.lua +++ b/awesome/rc.lua @@ -55,6 +55,7 @@ if (os.getenv("XDG_CONFIG_HOME")) then else config_dir = string.format("%s/.config", os.getenv("HOME")) end +awesome_config_folder = config_dir .. "awesome" theme.dir = string.format("%s/awesome/themes/%s", config_dir, theme.name) beautiful.init(theme.dir .. "/theme.lua") beautiful.useless_gap = 5 @@ -823,6 +824,12 @@ awful.rules.rules = { }, properties = { titlebars_enabled = true } }, + { rule_any = { + class = { + "mpv" + }, + }, properties = { size_hints_honor = false } }, + -- Set Firefox to always map on the tag named "2" on screen 1. -- { rule = { class = "Firefox" }, -- properties = { screen = 1, tag = "2" } }, @@ -830,10 +837,9 @@ awful.rules.rules = { -- }}} -- {{{ Window Swallowing functions - ---[[ +---[[ function is_terminal(c) - return (c.class and (c.class:match("Alacritty") or c.class:match("St"))) and true or false + return (c.class and c.class:match("St")) and true or false end function copy_size(c, parent_client) @@ -854,6 +860,25 @@ function check_resize_client(c) end end +function get_parent_pid(child_ppid, callback) + local ppid_cmd = string.format("ps -o ppid= -p %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", "") + callback(nil, ppid) + end) +end + +function if_client_and_parent(c1, c2, cl) + if c1 and (c1:find('^' .. cl.pid) or c2) then + return true + end +end + client.connect_signal("property::size", check_resize_client) client.connect_signal("property::position", check_resize_client) client.connect_signal("manage", function(c) @@ -861,57 +886,40 @@ client.connect_signal("manage", function(c) return end local parent_client=awful.client.focus.history.get(c.screen, 1) - if parent_client and is_terminal(parent_client) then - parent_client.child_resize=c - c.floating=true - copy_size(c, parent_client) - end -end) ---]] ---[[ -client.connect_signal("manage", function(c) - if is_terminal(c) then - return - end - local parent_client=awful.client.focus.history.get(c.screen, 1) - if parent_client and is_terminal(parent_client) then - parent_client.child_resize=c - parent_client.minimized = true - - c:connect_signal("unmanage", function() parent_client.minimized = false end) - - -- c.floating=true - copy_size(c, parent_client) - end -end) ---]] ---[[ -function is_terminal(c) - return (c.class and (c.class:match("Alacritty") or c.class:match("St"))) and true or false -end - --- swallow -client.connect_signal("manage", function(c) - if is_terminal(c) then - return - end - - local parent_client=awful.client.focus.history.get(c.screen, 1) - - awful.spawn.easy_async('dash '..awful.util.get_configuration_dir()..'helper.sh gppid '..c.pid, function (gppid) - awful.spawn.easy_async('dash '..awful.util.get_configuration_dir()..'helper.sh ppid '..c.pid, function(ppid) - if parent_client and (gppid:find('^' .. parent_client.pid) or ppid:find('^' .. parent_client.pid))and is_terminal(parent_client) then - parent_client.child_resize=c - parent_client.minimized = true - - c:connect_signal("unmanage", function() parent_client.minimized = false end) - - if (c.floating) then - copy_size(c, parent_client) + get_parent_pid(c.pid, function(err, ppid) + if err then + error(err) + return end - end + parent_pid = ppid or false + get_parent_pid(parent_pid, function(err, gppid) + if err then + error(err) + return + end + grand_parent_pid = gppid or false + get_parent_pid(grand_parent_pid, function(err, ggppid) + if err then + error(err) + return + end + great_grand_parent_pid = ggppid or false + get_parent_pid(great_grand_parent_pid, function(err, gggppid) + if err then + error(err) + return + end + great_great_grand_parent_pid = gggppid or false + --if parent_client and (parent_pid:find('^' .. parent_client.pid) or (grand_parent_pid and (grand_parent_pid:find('^' .. parent_client.pid) or (great_grand_parent_pid and great_grand_parent_pid:find('^' .. parent_client.pid))))) and is_terminal(parent_client) then + if parent_client and if_client_and_parent(parent_pid, if_client_and_parent(grand_parent_pid, if_client_and_parent(great_grand_parent_pid, great_great_grand_parent_pid, parent_client),parent_client), parent_client) and is_terminal(parent_client) then + parent_client.child_resize=c + c.floating=true + copy_size(c, parent_client) + end + end) + end) + end) end) - end) end) --]] -- }}} -- cgit v1.2.3