Skip to content

Instantly share code, notes, and snippets.

@tnymlr
Created June 2, 2019 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tnymlr/3d3eca75e46389916cc5a2a70f29775d to your computer and use it in GitHub Desktop.
Save tnymlr/3d3eca75e46389916cc5a2a70f29775d to your computer and use it in GitHub Desktop.
How to choose a window with dmenu in sway
swaymsg -t get_tree \
| jq -r '..| objects | select(.type == "con") | select(.name != null) | select(.nodes | length < 1) | {id: .id | tostring, name: .name, app_id: .app_id} | .id + ": " + .name + " - " + .app_id' \
| dmenu -l 30 \
| cut -d ':' -f 1 \
| xargs -I {} swaymsg '[con_id="{}"] focus'
@tnymlr
Copy link
Author

tnymlr commented Jun 2, 2019

This one will find all of the windows managed by sway, list them using dmenu allowing user to choose one with fuzzy search and then switch to the chosen window.

It works the same way if one replaces dmenu with bemenu

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment