51 lines
1.1 KiB
Bash
Executable File
51 lines
1.1 KiB
Bash
Executable File
#!/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
|