Files

22 lines
568 B
Bash
Raw Permalink Normal View History

#!/usr/bin/env bash
# Reads the system clipboard and pushes it to scrot as a `clip` blob.
set -euo pipefail
: "${SCROT_SERVER:?set SCROT_SERVER, e.g. https://scrot.example.com}"
: "${DEVICE_TOKEN:?set DEVICE_TOKEN}"
if [ -n "${WAYLAND_DISPLAY:-}" ]; then
content=$(wl-paste --no-newline)
else
content=$(xclip -selection clipboard -o)
fi
curl -sf -X POST "$SCROT_SERVER/api/blobs" \
-H "X-Device-Token: $DEVICE_TOKEN" \
-H "X-Blob-Kind: clip" \
-H "Content-Type: text/plain; charset=utf-8" \
--data-binary "$content" \
-o /dev/null
echo "clip pushed"