#!/usr/bin/env bash # file time=`date +%Y-%m-%d-%H-%M-%S` dir="`xdg-user-dir PICTURES`/Screenshots" file="Screenshot_${time}.png" # directory if [[ ! -d "$dir" ]]; then mkdir -p "$dir" fi trap notify EXIT notify () { notify_cmd_shot="notify-send -u low -i $dir/$file" echo $notify_cmd_shot pngcheck ${dir}/"$file" > /dev/null if [[ -e "$dir/$file" ]]; then ${notify_cmd_shot} "Screenshot Saved." "Screenshot saved in '$dir/$file'" echo $notify_cmd_shot "Screenshot Saved." "Screenshot saved in '$dir/$file'" else # ${notify_cmd_shot} "Screenshot Canceled." exit fi } # notify and view screenshot notify_view () { if [[ $? -eq 0 ]]; then #${notify_cmd_shot} "Copied to clipboard." if $($HOME/scripts/sysutil.sh getSound screenshot); then $HOME/scripts/sysutil.sh playSound screen-capture.oga & fi # viewnior ${dir}/"$file" # blobdrop -f gui ${dir}/"$file" -b -t & dragon-drop --icon-only --thumb-size 512 --and-exit ${dir}/"$file" & ( sleep 10 && kill $! ) & else # the notifcation too annoying #${notify_cmd_shot} "Screenshot Canceled." rm "${dir}/$file" exit 0 fi } # copy screenshot to clipboard copy_shot () { tee "${dir}/$file" | wl-copy -t image/png } # countdown countdown () { for sec in `seq $1 -1 1`; do dunstify -t 1000 -h string:x-dunst-stack-tag:screenshottimer -i /usr/share/archcraft/icons/dunst/timer.png "Taking shot in : $sec" sleep 1 done } # take shots shotnow () { grim - | copy_shot notify_view } shot5 () { countdown '5' sleep 1 && grim - | copy_shot notify_view } shot10 () { countdown '10' sleep 1 grim - | copy_shot notify_view } shotarea () { # g=$(wayfreeze --after-freeze-cmd "slurp -d; killall wayfreeze") g=$(slurp -d) if [[ -z "$g" ]]; then exit 0 fi grim -g "$g" - | copy_shot notify_view } # execute if [[ "$1" == "--now" ]]; then shotnow elif [[ "$1" == "--in5" ]]; then shot5 elif [[ "$1" == "--in10" ]]; then shot10 elif [[ "$1" == "--area" ]]; then shotarea else echo -e "Available Options : --now --in5 --in10 --area" fi exit 0