Skip to content

Instantly share code, notes, and snippets.

@digitalsignalperson
Created March 27, 2025 23:02
Show Gist options
  • Save digitalsignalperson/422d2af186033be8e8fdf32487a295e5 to your computer and use it in GitHub Desktop.
Save digitalsignalperson/422d2af186033be8e8fdf32487a295e5 to your computer and use it in GitHub Desktop.
kde fast screenshot
#!/bin/bash
cleanup(){
[[ -n $1 ]] && rm -f "$1"
}
tempfile=$(mktemp -t screenshot-XXXXXX.png)
trap "cleanup '$tempfile'" EXIT
spectacle --fullscreen --background --nonotify --output "$tempfile" &
geometry=$(slurp)
wait
if [ -z "$geometry" ]; then
exit 1
fi
read -r x y w h <<< $(echo "$geometry" | sed 's/,/ /' | sed 's/x/ /')
convert "$tempfile" -crop "${w}x${h}+${x}+${y}" PNG:- | wl-copy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment