docs: add interactive screenshot implementation plan
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,216 @@
|
||||
# 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**
|
||||
|
||||
```bash
|
||||
grep -E "satty|swappy" packages.txt
|
||||
```
|
||||
|
||||
Expected output:
|
||||
```
|
||||
satty
|
||||
swappy
|
||||
```
|
||||
|
||||
- [ ] **Step 3: Commit**
|
||||
|
||||
```bash
|
||||
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:
|
||||
|
||||
```bash
|
||||
#!/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**
|
||||
|
||||
```bash
|
||||
chmod +x scripts/screenshot.sh
|
||||
```
|
||||
|
||||
- [ ] **Step 3: Verify the symlink still points to the right place**
|
||||
|
||||
```bash
|
||||
ls -la ~/.local/bin/screenshot
|
||||
```
|
||||
|
||||
Expected: symlink pointing to `.../dotfiles/scripts/screenshot.sh`. If it is missing, run:
|
||||
|
||||
```bash
|
||||
ln -sf "$(pwd)/scripts/screenshot.sh" ~/.local/bin/screenshot
|
||||
```
|
||||
|
||||
- [ ] **Step 4: Commit**
|
||||
|
||||
```bash
|
||||
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**
|
||||
|
||||
```bash
|
||||
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.
|
||||
|
||||
```bash
|
||||
ls -t ~/Pictures/screenshot-*.png | head -1
|
||||
```
|
||||
|
||||
- [ ] **Step 2: Cancel capture**
|
||||
|
||||
```bash
|
||||
screenshot
|
||||
```
|
||||
|
||||
- Press Escape in slurp.
|
||||
- Expected: no notification, no file created.
|
||||
|
||||
- [ ] **Step 3: Actions → swappy**
|
||||
|
||||
```bash
|
||||
screenshot
|
||||
```
|
||||
|
||||
- Select a region, click "Actions", choose "Annotate with swappy".
|
||||
- Expected: swappy opens with the screenshot loaded.
|
||||
|
||||
- [ ] **Step 4: Actions → satty**
|
||||
|
||||
```bash
|
||||
screenshot
|
||||
```
|
||||
|
||||
- Select a region, click "Actions", choose "Annotate with satty".
|
||||
- Expected: satty opens with the screenshot loaded.
|
||||
|
||||
- [ ] **Step 5: Actions → imv**
|
||||
|
||||
```bash
|
||||
screenshot
|
||||
```
|
||||
|
||||
- Select a region, click "Actions", choose "Open in imv".
|
||||
- Expected: imv opens displaying the screenshot.
|
||||
|
||||
- [ ] **Step 6: Actions → Copy path**
|
||||
|
||||
```bash
|
||||
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`).
|
||||
|
||||
```bash
|
||||
wl-paste
|
||||
```
|
||||
|
||||
- [ ] **Step 7: Actions → Delete**
|
||||
|
||||
```bash
|
||||
screenshot
|
||||
```
|
||||
|
||||
- Select a region, click "Actions", choose "Delete".
|
||||
- Expected: notification "Screenshot deleted" fires; file is gone.
|
||||
|
||||
```bash
|
||||
ls ~/Pictures/screenshot-*.png | tail -1 # should not include the just-deleted file
|
||||
```
|
||||
|
||||
- [ ] **Step 8: Actions → Escape wofi**
|
||||
|
||||
```bash
|
||||
screenshot
|
||||
```
|
||||
|
||||
- Select a region, click "Actions", then press Escape in wofi.
|
||||
- Expected: nothing happens; file and clipboard copy are preserved.
|
||||
Reference in New Issue
Block a user