Skip to content

Instantly share code, notes, and snippets.

@pgaskin
Created August 1, 2019 02:00
Show Gist options
  • Select an option

  • Save pgaskin/44a8fbbc52b86b087c7838677dd29c53 to your computer and use it in GitHub Desktop.

Select an option

Save pgaskin/44a8fbbc52b86b087c7838677dd29c53 to your computer and use it in GitHub Desktop.
i3 dmenu script to choose between windows on the current workspace.
#!/bin/sh
fws="$(i3-msg -t get_workspaces | jq -c '[ .[] | select(.focused).num ][0]')"
wnd="$(i3-msg -t get_tree | jq --argjson fws "$fws" -c '[[ .. | select(.>={} and .type == "workspace" and .num == $fws) | .. | select(.>={} and .type == "con" and .name) ] | to_entries | .[] | [.value.id, (.key + 1 | tostring) + ". " + .value.name ]]')"
sel="$(echo "$wnd" | jq -r '.[][1]' | dmenu -i | cut -d '.' -f1)"
test -z "$sel" || cid="$(echo "$wnd" | jq --argjson sel "$sel" -r '.[$sel-1][0]')"
test -z "$cid" || i3-msg "[con_id=$cid]" focus
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment