#!/bin/bash
# Window switcher for niri using wofi dmenu
focused=$(niri msg -j focused-window 2>/dev/null | jq -r '.id // ""')

selection=$(niri msg -j windows 2>/dev/null \
    | jq -r '.[] | "\(.id) ┇ \(.app_id // "?") ┇ \(.title // "?")"' \
    | wofi -dO alphabetical --prompt "Switch to:" \
    | awk '{print $1}')

if [ -n "$selection" ]; then
    niri msg action focus-window --id "$selection"
fi
