dotfiles/.scripts/grim.sh
2023-09-26 17:12:28 +02:00

34 lines
631 B
Bash
Executable file

#!/bin/sh
usage="Usage: $(basename "$0") screen | window | region"
if [[ $# -ne 1 ]]; then
echo "$usage"
exit 1
fi
case "$1" in
screen)
grim - | wl-copy
;;
window)
grim -g "$(hyprctl activewindow -j | jq -r '"\(.at[0]),\(.at[1]) \(.size[0])x\(.size[1])"')" - | wl-copy
;;
region)
region="$(slurp)"
[[ $? -ne 0 ]] && exit 1
grim -g "$region" - | wl-copy
;;
*)
echo "$usage"
exit 1
;;
esac
img_name="$(date +'%Y-%m-%d_%H-%M-%S'_grim.png)"
wl-paste -t image > "$GRIM_DEFAULT_DIR/$img_name"
notify-send "Grim" "Screenshot saved to $img_name"