22 lines
613 B
Bash
Executable File
22 lines
613 B
Bash
Executable File
#!/bin/bash
|
|
|
|
parent_has_sibl=$(swaymsg -t get_tree | jq '
|
|
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;
|
|
|
|
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
|
|
swaymsg "focus $1 sibling; focus child"
|
|
fi
|