Files
scripts/hypr/popup.sh
T
adamfandClaude Opus 5.5 c00705a24a Add Kando pie menu of cursor-following popups and aichat quick role
Replace cursor_ask.sh with popup.sh launching popups from a Kando
"popups" menu; cursor_follow.lua gains a popups table (sizes, follow
until Enter, stay_focused) and pauses following while Kando is open.
Add aichat config/role for the quick Claude popup and Kando
menu/theme configs, with gen-colors syncing the Kando theme palette.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-26 12:23:01 +00:00

47 lines
1.8 KiB
Bash
Executable File

#!/bin/bash
# popup: open one of the popups in the SUPER+A pie menu (Kando runs `popup.sh <name>`)
# cursor_follow.lua places each popup window beside the cursor by its class, and the keyboard
# ones (ai, term) follow it until Enter is pressed in them.
kitty=(kitty -o confirm_os_window_close=0 -o window_padding_width=10)
# aichat's config and quick role live next to this script; the API key is in ~/.config/aichat/.env
export AICHAT_CONFIG_FILE="$HOME/.config/hypr/aichat/config.yaml"
export AICHAT_ROLES_DIR="$HOME/.config/hypr/aichat/roles"
case $1 in
ai)
exec "${kitty[@]}" --class popup-ai -o 'map escape close_window' -e aichat
;;
region) # ask the AI about a dragged-out screen region
geometry=$(slurp) || exit
img=$(mktemp --suffix=.png)
grim -g "$geometry" "$img" || exit
exec "${kitty[@]}" --class popup-ai -o 'map escape close_window' -e "$0" region-chat "$img"
;;
region-chat) # runs inside the region popup: ask about the screenshot, then keep chatting about it
read -e -r -p $'\001\e[36m\002about this region> \001\e[0m\002' q
aichat --empty-session --save-session -s region -r quick -f "$2" "${q:-What is this?}"
rm -f "$2"
exec aichat -s region
;;
receipt) # the receipt printer page, served here while the Pi is down, otherwise by the website
url=https://www.adam-french.co.uk/receipt/
curl -sf -m 1 http://127.0.0.1:8765/healthz >/dev/null && url=http://127.0.0.1:8765/
# Chromium names an app window's class after its URL, so cursor_follow.lua knows both of these
exec chromium --no-first-run --no-default-browser-check --app="$url"
;;
sticky)
exec hyprctl dispatch 'require("cursor_follow").toggle_sticky'
;;
term)
exec "${kitty[@]}" --class popup-term
;;
audio)
exec pavucontrol
;;
*)
echo "usage: popup.sh ai|region|receipt|sticky|term|audio" >&2
exit 1
;;
esac