phase 7b: Dolphin service menus

- Right-click file → 'Ask Ollie about this' (one-shot with kdialog popup)
- Right-click directory → 'Start Ollie session here'
- ollie-ask helper script: creates session, submits, waits, shows result
- make dolphin-install target
This commit is contained in:
Levi Neely 2026-07-05 23:38:57 +02:00
parent 2767387f8e
commit eab8cfa635
4 changed files with 109 additions and 0 deletions

View File

@ -38,6 +38,13 @@ clean:
rm -rf $(BUILD_DIR)
rm -f $(LIB_DIR)/libollie.so $(LIB_DIR)/libollie.h
# Install Dolphin service menus
dolphin-install:
mkdir -p ~/.local/share/kio/servicemenus
cp dolphin/ollie-actions.desktop ~/.local/share/kio/servicemenus/
sudo cp dolphin/ollie-ask /usr/local/bin/
@echo "Dolphin menus installed. Restart Dolphin or re-open context menu."
# Install plasmoid to user's local plasma directory
plasmoid-install: daemon
kpackagetool6 -t Plasma/Applet -u plasmoid/ 2>/dev/null || \

View File

@ -0,0 +1,15 @@
[Desktop Entry]
Type=Service
MimeType=all/allfiles;inode/directory;
Actions=askOllie;sessionHere;
X-KDE-AuthorizeAction=shell_access
[Desktop Action askOllie]
Name=Ask Ollie about this
Icon=system-run
Exec=ollie-ask %f
[Desktop Action sessionHere]
Name=Start Ollie session here
Icon=system-run
Exec=ollie-session-here %f

76
dolphin/ollie-ask Executable file
View File

@ -0,0 +1,76 @@
#!/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:}"
CWD="$(dirname "$TARGET")"
PROMPT="$PREFIX $TARGET"
SERVICE="org.ollie.SessionManager"
OBJ="/org/ollie/SessionManager"
IFACE="org.ollie.SessionManager"
# Create session
SESSION=$(dbus-send --session --dest=$SERVICE --type=method_call --print-reply \
$OBJ $IFACE.CreateSession \
string:"$CWD" string:"" string:"" string:"default" 2>/dev/null | \
awk -F'"' '/string "/{print $2; exit}')
if [ -z "$SESSION" ]; then
notify-send "Ollie" "Failed to create session"
exit 1
fi
# Submit
dbus-send --session --dest=$SERVICE --type=method_call --print-reply \
$OBJ $IFACE.Submit string:"$SESSION" string:"$PROMPT" > /dev/null 2>&1
# Wait for agent to start (state becomes non-idle)
i=0
while [ $i -lt 20 ]; do
STATE=$(dbus-send --session --dest=$SERVICE --type=method_call --print-reply \
$OBJ $IFACE.GetState string:"$SESSION" 2>/dev/null | \
awk -F'"' '/string "/{print $2; exit}')
[ "$STATE" != "idle" ] && break
sleep 0.2
i=$((i + 1))
done
# Wait for agent to finish (state returns to idle, max 60s)
i=0
while [ $i -lt 120 ]; do
STATE=$(dbus-send --session --dest=$SERVICE --type=method_call --print-reply \
$OBJ $IFACE.GetState string:"$SESSION" 2>/dev/null | \
awk -F'"' '/string "/{print $2; exit}')
[ "$STATE" = "idle" ] && break
sleep 0.5
i=$((i + 1))
done
# Get chat via gdbus
RESULT=$(gdbus call --session --dest $SERVICE --object-path $OBJ \
--method $IFACE.GetChat "$SESSION" 0 2>/dev/null | \
sed "s/^('//; s/', int64 [0-9]*)$//; s/\\\\n/\n/g")
# Extract assistant response
ASSISTANT=$(printf '%s\n' "$RESULT" | sed -n '/^\[assistant\]$/,/^\[/{/^\[assistant\]$/d; /^\[/d; p;}')
[ -z "$ASSISTANT" ] && ASSISTANT="$RESULT"
# Kill session
dbus-send --session --dest=$SERVICE --type=method_call \
$OBJ $IFACE.KillSession string:"$SESSION" > /dev/null 2>&1
# Show result
TMPFILE=$(mktemp /tmp/ollie-ask.XXXXXX)
printf '%s' "$ASSISTANT" > "$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" "$ASSISTANT"
fi
rm -f "$TMPFILE"

11
dolphin/ollie-session-here Executable file
View File

@ -0,0 +1,11 @@
#!/bin/sh
# ollie-session-here: start a session in the given directory
TARGET="$1"
[ -f "$TARGET" ] && TARGET="$(dirname "$TARGET")"
[ -z "$TARGET" ] && TARGET="$HOME"
dbus-send --session --dest=org.ollie.SessionManager --type=method_call \
/org/ollie/SessionManager org.ollie.SessionManager.CreateSession \
string:"$TARGET" string:"" string:"" string:"default"
notify-send -t 3000 "Ollie" "Session started in $TARGET"