29 lines
514 B
Bash
Executable File
29 lines
514 B
Bash
Executable File
#!/usr/bin/env bash
|
|
set -e
|
|
|
|
set -a
|
|
source ~/.config/imgshare.env
|
|
set +a
|
|
|
|
TOKEN="${IMGSHARE_TOKEN:?IMGSHARE_TOKEN not set}"
|
|
ENDPOINT="https://share.caio.wakamatsu.cc/upload"
|
|
|
|
tmp=$(mktemp --suffix=.png)
|
|
|
|
grim -g "$(slurp)" "$tmp"
|
|
swappy -f "$tmp" -o "$tmp"
|
|
|
|
resp=$(curl -s "$ENDPOINT" \
|
|
-H "Authorization: Bearer $TOKEN" \
|
|
-F "file=@$tmp")
|
|
|
|
url=$(echo "$resp" | jq -r '.url // empty')
|
|
|
|
if [[ -n "$url" ]]; then
|
|
echo "https://share.caio.wakamatsu.cc$url" | wl-copy
|
|
notify-send "Uploaded Image"
|
|
fi
|
|
|
|
rm "$tmp"
|
|
|