Spectacle on KDE
KDE's screenshot tool, run from a script that uploads and copies the link.
1. Make an uploader on your server
- Sign in to your server and open Settings > Uploaders, then Add uploader.
- Pick Spectacle, give it a name you'll recognize, and check the folder, visibility and link style. The defaults are fine.
- The next page has these same steps with your server and token already filled in. The token is shown once, so copy it or download the files now.
The snippets below use https://drive.example.com and stu_YOUR_UPLOADER_TOKEN. Swap in your own if you set things up by hand.
2. Install
- Install curl, jq and a clipboard tool if you don't have them:
sudo apt install curl jq wl-clipboard xclip - Download
stavo-spectacle.shfrom the uploader's page (or save the script below), put it in~/.local/binand make it runnable:mkdir -p ~/.local/bin mv ~/Downloads/stavo-spectacle.sh ~/.local/bin/ chmod +x ~/.local/bin/stavo-spectacle.sh - System Settings > Keyboard > Shortcuts > Add New > Command or Script, enter the line below and pick a key.
~/.local/bin/stavo-spectacle.sh - Press the key and select an area. The link is on your clipboard. For the whole screen change
-rto-fin the script, or-afor the active window.
The script
#!/usr/bin/env bash
# Spectacle: select an area, it uploads and copies the link.
# Pass file paths to upload those instead.
# Needs: spectacle, curl, jq, and wl-copy (Wayland) or xclip (X11).
set -euo pipefail
SERVER="https://drive.example.com"
TOKEN="stu_YOUR_UPLOADER_TOKEN"
upload() {
local resp url
resp="$(curl -sS -H "Authorization: Bearer $TOKEN" -F "file=@$1" "$SERVER/api/v1/upload")" || { notify-send "Upload failed" "Couldn't reach $SERVER"; exit 1; }
url="$(printf '%s' "$resp" | jq -r '.url // empty')"
if [ -z "$url" ]; then
notify-send "Upload failed" "$(printf '%s' "$resp" | jq -r '.error // "No answer from the server"')"
exit 1
fi
if [ -n "${WAYLAND_DISPLAY:-}" ] && command -v wl-copy >/dev/null; then printf '%s' "$url" | wl-copy
else printf '%s' "$url" | xclip -selection clipboard; fi
notify-send "Link copied" "$url"
}
if [ "$#" -gt 0 ]; then
for f in "$@"; do upload "$f"; done
exit 0
fi
tmp="$(mktemp -d)"
trap 'rm -rf "$tmp"' EXIT
shot="$tmp/screenshot-$(date +%Y-%m-%d-%H%M%S).png"
# -b background, -n no notification, -r region, -o output file. Use -f for the screen or -a for the active window.
spectacle -b -n -r -o "$shot" || true
[ -s "$shot" ] || exit 0
upload "$shot"