#!/bin/env sh

options=$(hyprctl -j clients | jq 'map({"\(.title)": .pid}) | add')
result=$(echo $options | jq 'keys | map("\(.)\n") | add' -r | anyrun --plugins libstdin.so)

pid=$(echo $options | jq ".[\"$result\"]")

if [[ $pid == "null" ]]; then
  exit 0
fi

hyprctl dispatch focuswindow pid:$pid
