Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
4.7 KiB
Interactive Screenshot Script Implementation Plan
For agentic workers: REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (
- [ ]) syntax for tracking.
Goal: Rewrite scripts/screenshot.sh so that after capture a mako notification appears with an "Actions" button that opens a wofi dmenu picker (swappy, satty, imv, copy path, delete).
Architecture: Single bash script. Capture → clipboard → blocking notify-send --action → if "Actions" clicked, pipe options into wofi --dmenu → execute chosen action. No new files beyond the script itself.
Tech Stack: bash, grim, slurp, wl-copy, notify-send (libnotify), wofi, swappy, satty, imv
Task 1: Add satty and swappy to packages.txt
Files:
-
Modify:
packages.txt -
Step 1: Append the two packages
Open packages.txt and add these two lines at the end:
satty
swappy
- Step 2: Verify
grep -E "satty|swappy" packages.txt
Expected output:
satty
swappy
- Step 3: Commit
git add packages.txt
git commit -m "packages: add satty and swappy"
Task 2: Rewrite screenshot.sh
Files:
-
Modify:
scripts/screenshot.sh -
Step 1: Write the new script
Replace the full contents of scripts/screenshot.sh with:
#!/bin/bash
FILE="$HOME/Pictures/screenshot-$(date +%s).png"
# Exit silently if the user cancels region selection
if ! grim -g "$(slurp)" "$FILE"; then
exit 0
fi
wl-copy < "$FILE"
action=$(notify-send "Screenshot captured" \
"Saved · Copied to clipboard" \
--hint="string:image-path:$FILE" \
--expire-time=10000 \
--action="actions=Actions")
[[ "$action" != "actions" ]] && exit 0
choice=$(printf 'Annotate with swappy\nAnnotate with satty\nOpen in imv\nCopy path\nDelete' \
| wofi --dmenu --prompt "Screenshot")
case "$choice" in
"Annotate with swappy")
swappy -f "$FILE" &
;;
"Annotate with satty")
satty --filename "$FILE" &
;;
"Open in imv")
imv "$FILE" &
;;
"Copy path")
printf '%s' "$FILE" | wl-copy
notify-send "Path copied" "$FILE"
;;
"Delete")
rm "$FILE"
notify-send "Screenshot deleted" "File removed"
;;
esac
- Step 2: Ensure it is executable
chmod +x scripts/screenshot.sh
- Step 3: Verify the symlink still points to the right place
ls -la ~/.local/bin/screenshot
Expected: symlink pointing to .../dotfiles/scripts/screenshot.sh. If it is missing, run:
ln -sf "$(pwd)/scripts/screenshot.sh" ~/.local/bin/screenshot
- Step 4: Commit
git add scripts/screenshot.sh
git commit -m "screenshot: add post-capture notification and wofi action picker"
Task 3: Smoke test
No Wayland-aware unit test framework is available, so verification is manual. Run through each path once.
- Step 1: Basic capture → dismiss
screenshot
- Select a region with slurp.
- Notification appears: "Screenshot captured / Saved · Copied to clipboard".
- Dismiss or wait 10 s for it to expire.
- Expected: file exists in
~/Pictures/, clipboard contains the image, nothing else happens.
ls -t ~/Pictures/screenshot-*.png | head -1
- Step 2: Cancel capture
screenshot
-
Press Escape in slurp.
-
Expected: no notification, no file created.
-
Step 3: Actions → swappy
screenshot
-
Select a region, click "Actions", choose "Annotate with swappy".
-
Expected: swappy opens with the screenshot loaded.
-
Step 4: Actions → satty
screenshot
-
Select a region, click "Actions", choose "Annotate with satty".
-
Expected: satty opens with the screenshot loaded.
-
Step 5: Actions → imv
screenshot
-
Select a region, click "Actions", choose "Open in imv".
-
Expected: imv opens displaying the screenshot.
-
Step 6: Actions → Copy path
screenshot
- Select a region, click "Actions", choose "Copy path".
- Expected: second notification "Path copied" fires; clipboard now contains the file path (verify with
wl-paste).
wl-paste
- Step 7: Actions → Delete
screenshot
- Select a region, click "Actions", choose "Delete".
- Expected: notification "Screenshot deleted" fires; file is gone.
ls ~/Pictures/screenshot-*.png | tail -1 # should not include the just-deleted file
- Step 8: Actions → Escape wofi
screenshot
- Select a region, click "Actions", then press Escape in wofi.
- Expected: nothing happens; file and clipboard copy are preserved.