Initial scaffold: blob store server, CLI scripts, and PWA share target
Clipboard/screenshot sync across own devices via a single DEVICE_TOKEN-gated blob store, plus a small installable web app so a phone can push/pull clips and share screenshots via the OS share sheet.
This commit is contained in:
Executable
+33
@@ -0,0 +1,33 @@
|
||||
#!/usr/bin/env bash
|
||||
# Captures a region screenshot, pushes it to scrot as a `shot` blob, and
|
||||
# copies the returned public link to the clipboard.
|
||||
set -euo pipefail
|
||||
|
||||
: "${SCROT_SERVER:?set SCROT_SERVER, e.g. https://scrot.example.com}"
|
||||
: "${DEVICE_TOKEN:?set DEVICE_TOKEN}"
|
||||
|
||||
tmpfile=$(mktemp --suffix=.png)
|
||||
trap 'rm -f "$tmpfile"' EXIT
|
||||
|
||||
if [ -n "${WAYLAND_DISPLAY:-}" ]; then
|
||||
grim -g "$(slurp)" "$tmpfile"
|
||||
else
|
||||
maim -s "$tmpfile"
|
||||
fi
|
||||
|
||||
response=$(curl -sf -X POST "$SCROT_SERVER/api/blobs" \
|
||||
-H "X-Device-Token: $DEVICE_TOKEN" \
|
||||
-H "X-Blob-Kind: shot" \
|
||||
-H "Content-Type: image/png" \
|
||||
--data-binary "@$tmpfile")
|
||||
|
||||
url=$(printf '%s' "$response" | grep -o '"url":"[^"]*"' | cut -d'"' -f4)
|
||||
full_url="$SCROT_SERVER$url"
|
||||
|
||||
if [ -n "${WAYLAND_DISPLAY:-}" ]; then
|
||||
printf '%s' "$full_url" | wl-copy
|
||||
else
|
||||
printf '%s' "$full_url" | xclip -selection clipboard
|
||||
fi
|
||||
|
||||
echo "screenshot uploaded: $full_url"
|
||||
Reference in New Issue
Block a user