Uploaders

Flameshot on Linux

Select an area with Flameshot, it uploads to your server and copies the link.

Flameshot doesn't have custom uploaders built in, so a small script does the work: flameshot gui --raw captures, curl uploads, jq reads the answer and the link goes to your clipboard.

1. Make an uploader on your server

  1. Sign in to your server and open Settings > Uploaders, then Add uploader.
  2. Pick Flameshot, give it a name you'll recognize, and check the folder, visibility and link style. The defaults are fine.
  3. 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

  1. Install what the script uses (Debian and Ubuntu shown; use your package manager):
    bash
    sudo apt install flameshot curl jq libnotify-bin wl-clipboard xclip
  2. Download stavo-flameshot.sh from the uploader's page (or save the script below), put it in ~/.local/bin and make it runnable:
    bash
    mkdir -p ~/.local/bin
    mv ~/Downloads/stavo-flameshot.sh ~/.local/bin/
    chmod +x ~/.local/bin/stavo-flameshot.sh
  3. Bind a key: in your desktop's keyboard settings add a custom shortcut (for example Ctrl+Shift+4) that runs:
    bash
    ~/.local/bin/stavo-flameshot.sh
  4. Press the key, select an area and press Enter. The link is on your clipboard.

The script

bash
#!/usr/bin/env bash
# Flameshot: select an area (Enter to finish), it uploads and copies the link.
# Pass file paths to upload those instead.
# Needs: flameshot, 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"
flameshot gui --raw > "$shot" 2>/dev/null || true
[ -s "$shot" ] || exit 0
upload "$shot"