This repository has been archived on 2026-08-16. You can view files and clone it, but cannot push or open issues or pull requests.
ollie-kde/dolphin/ollie-ask

34 lines
1.0 KiB
Bash
Executable File

#!/bin/sh
# ollie-ask: one-shot prompt helper for Dolphin service menus
# Usage: ollie-ask <file_or_dir> [prompt_prefix]
TARGET="$1"
PREFIX="${2:-Describe and explain this file:}"
PROMPT="$PREFIX $TARGET"
# Ensure default session and agent exist
printf 'name=default\ncwd=%s\n' "$HOME" | ollie-9p write session/new 2>/dev/null
printf 'cwd=%s\n' "$HOME" | ollie-9p write session/default/agent/new 2>/dev/null
# Use Generate one-shot via 9P
RESULT=$(echo "$PROMPT" | ollie-9p rdwr generate 2>/dev/null)
if [ -z "$RESULT" ]; then
notify-send "Ollie" "No response (is olliesrv running?)"
exit 1
fi
# Show result
TMPFILE=$(mktemp /tmp/ollie-ask.XXXXXX)
printf '%s' "$RESULT" > "$TMPFILE"
if command -v kdialog > /dev/null 2>&1; then
kdialog --title "Ollie — $(basename "$TARGET")" --textbox "$TMPFILE" 600 400
elif command -v zenity > /dev/null 2>&1; then
zenity --text-info --title="Ollie — $(basename "$TARGET")" --width=600 --height=400 --filename="$TMPFILE"
else
notify-send -t 30000 "Ollie" "$RESULT"
fi
rm -f "$TMPFILE"