Files
infra/dotfiles/desktop/.config/hypr/scripts/screenshot
2026-06-06 16:08:35 +02:00

39 lines
912 B
Bash
Executable File

#!/bin/sh
# Quick screenshot helpers for Hyprland. Captures via grim, saves to disk and
# also copies to the Wayland clipboard. Use the flameshot binding for
# annotations / fancy capture.
#
# Usage: screenshot {full|region|output|window}
set -eu
mode="${1:-full}"
dir="$HOME/Pictures/Screenshots"
mkdir -p "$dir"
file="$dir/$(date +%Y%m%d_%H%M%S).png"
case "$mode" in
full)
grim "$file"
;;
region)
grim -g "$(slurp)" "$file"
;;
output)
out=$(hyprctl monitors -j | jq -r '.[] | select(.focused == true) | .name')
grim -o "$out" "$file"
;;
window)
geom=$(hyprctl activewindow -j \
| jq -r '"\(.at[0]),\(.at[1]) \(.size[0])x\(.size[1])"')
grim -g "$geom" "$file"
;;
*)
printf 'Usage: %s {full|region|output|window}\n' "$0" >&2
exit 1
;;
esac
wl-copy < "$file"
notify-send "Screenshot saved" "$file" -i image-x-generic >/dev/null 2>&1 || true