Files
hypr/scripts/screenshot/screenshot_monitor.sh
T

34 lines
925 B
Bash
Executable File

#!/bin/bash
###
### ~/.config/hypr/scripts/screenshot/screenshot_monitor.sh
###
time=$(date +%Y-%m-%d-%H%M%S)
dir="$(xdg-user-dir PICTURES)/Screenshots"
monitor=$(hyprctl monitors -j | jq -r '.[] | select(.focused) | .name')
[ -n "$monitor" ] || exit 1
file="Screenshot_${time}_${monitor}.png"
mkdir -p "$dir"
# Capture the focused monitor, save it and copy to clipboard
grim -o "$monitor" "$dir/$file" || exit 1
wl-copy -t image/png < "$dir/$file"
if command -v notify-send >/dev/null 2>&1; then
notify-send -a Screenshot -i camera-photo "Screenshot saved" "$file"
fi
# Open the editor if swappy is available (blocks until it is closed)
if command -v swappy >/dev/null 2>&1; then
swappy -f "$dir/$file"
wl-copy -t image/png < "$dir/$file"
fi
# Compress the resulting image in the background if oxipng is available
if command -v oxipng >/dev/null 2>&1; then
oxipng --strip safe -o 4 "$dir/$file" &
fi