#!/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 end; find_focused_path | if length >= 3 and .[-2].type=="con" then 1 else 0 end ') if [ "$parent_has_sibl" = 1 ]; then swaymsg "focus parent; focus $1 sibling; focus child" else swaymsg "focus $1 sibling; focus child" fi