Skip to content

Instantly share code, notes, and snippets.

@bend-n
Created November 18, 2025 12:56
Show Gist options
  • Select an option

  • Save bend-n/f0d066ad99f2fdadec174cdc6d143bf2 to your computer and use it in GitHub Desktop.

Select an option

Save bend-n/f0d066ad99f2fdadec174cdc6d143bf2 to your computer and use it in GitHub Desktop.
#!/bin/bash
# adaptation of https://github.com/armerpunkt/niri-fuzzel-switcher
window_ids=()
window_titles=()
while read i; do
declare -a line_array="($i)"
window_ids+=(${line_array[0]})
window_titles+=("${line_array[1]} - ${line_array[2]} \0icon\x1f${line_array[1]}")
done <<<$(niri msg --json windows | jq -r 'sort_by(.layout.pos_in_scrolling_layout[0]) | .[] | [ .id, .app_id, .title] | "\""+join ("\" \"")+"\""')
sel=$(niri msg --json windows | jq "[ sort_by(.layout.pos_in_scrolling_layout[0]).[].is_focused ] | index(true)")
result=$(printf "%b\n" "${window_titles[@]}" | fuzzel --counter --dmenu --index --select-index $sel)
if [ "x$result" != "x" ] && [ $result != -1 ]; then
niri msg action focus-window --id ${window_ids[result]}
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment