Files
Minimal-Debian-Desktop/home/.local/bin/screenshot
T
2026-11-17 09:28:47 +01:00

51 lines
1.1 KiB
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/bin/sh
# screenshot – Bildschirmfoto unter labwc (Wayland)
# Benötigt: grim, slurp, wl-clipboard (optional: libnotify-bin)
set -eu
mode="${1:-full}"
dir="${XDG_PICTURES_DIR:-$HOME/Bilder}/Screenshots"
mkdir -p "$dir"
file="$dir/$(date +%Y-%m-%d_%H-%M-%S).png"
need() {
if ! command -v "$1" >/dev/null 2>&1; then
echo "screenshot: '$1' fehlt." >&2
echo "Installieren mit: sudo apt install grim slurp wl-clipboard" >&2
exit 1
fi
}
need grim
case "$mode" in
full)
grim "$file"
;;
region)
need slurp
geom="$(slurp)" || exit 0
grim -g "$geom" "$file"
;;
output)
need slurp
geom="$(slurp -o -r)" || exit 0
grim -g "$geom" "$file"
;;
*)
echo "Verwendung: screenshot [full|region|output]" >&2
exit 2
;;
esac
# In die Zwischenablage kopieren
if command -v wl-copy >/dev/null 2>&1; then
wl-copy --type image/png < "$file"
fi
# Kurze Benachrichtigung, falls libnotify vorhanden ist
if command -v notify-send >/dev/null 2>&1; then
notify-send -a Screenshot "Screenshot gespeichert" "$file"
fi