grim and slurp on Wayland
For Sway, Hyprland and other wlroots desktops: slurp selects, grim captures, the link lands on your clipboard.
1. Make an uploader on your server
- Sign in to your server and open Settings > Uploaders, then Add uploader.
- Pick grim and slurp, 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 the tools (Arch shown; the names are the same on most distributions):
sudo pacman -S grim slurp wl-clipboard curl jq libnotify - Download
stavo-grim.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-grim.sh ~/.local/bin/ chmod +x ~/.local/bin/stavo-grim.sh - Bind a key. Sway, in
~/.config/sway/config:Hyprland, inbindsym $mod+Shift+s exec ~/.local/bin/stavo-grim.sh~/.config/hypr/hyprland.conf:bind = SUPER SHIFT, S, exec, ~/.local/bin/stavo-grim.sh - Press the key and drag over an area. The link is on your clipboard.
The script
#!/usr/bin/env bash
# grim and slurp: drag over an area, it uploads and copies the link.
# Pass file paths to upload those instead.
# Needs: grim, slurp, curl, jq, wl-copy (wl-clipboard) and notify-send.
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
printf '%s' "$url" | wl-copy
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"
region="$(slurp)" || exit 0
grim -g "$region" "$shot"
upload "$shot"