#!/usr/bin/env bash ## Script to take screenshots with grim, slurp (in Wayland) iDIR="$HOME/.config/hypr/mako/icons" time=$(date +%Y-%m-%d-%H-%M-%S) dir="$(xdg-user-dir PICTURES)/Screenshots" # need file="Screenshot_${time}_${RANDOM}.png" # notify and view screenshot notify_cmd_shot="notify-send -h string:x-canonical-private-synchronous:shot-notify -u low -i ${iDIR}/picture.png" notify_view () { ${notify_cmd_shot} "Copied to clipboard." imv ${dir}/"$file" if [[ -e "$dir/$file" ]]; then ${notify_cmd_shot} "Screenshot Saved." else ${notify_cmd_shot} "Screenshot Deleted." fi } # take shots shotnow () { cd ${dir} && grim - | tee "$file" | wl-copy notify_view } shotwin () { w_pos=$(hyprctl activewindow | grep 'at:' | cut -d':' -f2 | tr -d ' ' | tail -n1) w_size=$(hyprctl activewindow | grep 'size:' | cut -d':' -f2 | tr -d ' ' | tail -n1 | sed s/,/x/g) cd ${dir} && grim -g "$w_pos $w_size" - | tee "$file" | wl-copy notify_view } shotarea () { cd ${dir} && grim -g "$(slurp -b 1B1F28CC -c E06B74ff -s C778DD0D -w 2)" - | tee "$file" | wl-copy notify_view } if [[ ! -d "$dir" ]]; then mkdir -p "$dir" fi if [[ "$1" == "--now" ]]; then shotnow elif [[ "$1" == "--area" ]]; then shotarea elif [[ "$1" == "--win" ]]; then shotwin else echo -e "Available Options : --now --win --area" fi exit 0