Created
June 28, 2021 20:35
-
-
Save chr5tphr/e49948b0e5ab6a4ffd143fc3e548a4d9 to your computer and use it in GitHub Desktop.
Find a window in sway with wofi and use use it as a criterion in a swaymsg.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
JQWINS=' | |
[recurse(.nodes[])] | | |
[ | |
.[] | | |
select(has("app_id")) | | |
(.id | tostring) + "\t" + .name + (" [" + if .app_id then .app_id else .shell end + "]") | |
] | | |
join("\n") | |
' | |
mapfile -t windows < <(swaymsg -t get_tree | jq -r "${JQWINS}") | |
identifiers=("${windows[@]%%$'\t'*}") | |
names=("${windows[@]##*$'\t'}") | |
index="$(wofi --dmenu -i -D dmenu-print_line_num=true < <(printf '%s\n' "${names[@]}") 2>/dev/null)" | |
[ -z "$index" ] || swaymsg "[con_id=${identifiers[${index}]}]" "${@:-focus}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment