This commit is contained in:
2025-09-26 05:08:39 +00:00
parent d8eae8a1a5
commit 6bf779a68e
6 changed files with 42 additions and 34 deletions

View File

@@ -1,15 +1,19 @@
#!/bin/bash
parent_has_sibl=$(swaymsg -t get_tree | jq '
def find_focused_path:
if .focused then [.]
elif .nodes then
[.] + (.nodes[] | find_focused_path | select(length > 0))
else empty
def check_focused(parent; grandparent):
if .focused then
if grandparent and (grandparent.type == "con" or grandparent.type == "workspace") and (grandparent.nodes | length) > 1 then 1 else 0 end
else
. as $current |
((.nodes[]? | check_focused($current; parent)),
(.floating_nodes[]? | check_focused($current; parent)))
end;
find_focused_path | if length >= 3 and .[-2].type=="con" then 1 else 0 end
first(check_focused(null; null) // 0)
')
#echo "$parent_has_sibl"
if [ "$parent_has_sibl" = 1 ]; then
swaymsg "focus parent; focus $1 sibling; focus child"
else