package sway import ( "context" "encoding/json" "os/exec" ) func GetTree(ctx context.Context) (*Node, error) { cmd := exec.CommandContext(ctx, "swaymsg", "-t", "get_tree") data, err := cmd.Output() if err != nil { return nil, err } var root Node if err := json.Unmarshal(data, &root); err != nil { return nil, err } return &root, nil }