Last active
June 2, 2021 20:48
-
-
Save CIAvash/ac323bdf775210a272a28707c6b123ba to your computer and use it in GitHub Desktop.
Switch windows in sway with rofi(dmenu)
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 | |
windows=$(swaymsg -t get_tree | jq -r '.. | select(.type? and .type=="workspace") | {workspace: .name, node: recurse(.nodes[], .floating_nodes[])} | "[\(.workspace)]:" + if .node.focused then "*" else "" end + " \(.node.id): " + if .node.app_id then "\(.node.app_id)" elif .node.window then "\(.node.window_properties.class)" else empty end + ": \(.node.name)"') | |
active_window=$(echo "$windows" | grep -nE '^\[[[:alnum:]]+\]:\*' | cut -d : -f 1) | |
echo "$windows" | rofi -dmenu -a $(($active_window - 1)) -i -p 'Select window: ' | cut -d : -f 2 | xargs -I{} swaymsg '[con_id={}] focus' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment