screenshot (1308B)
1 #!/bin/sh 2 TIMER=0 3 ACTIVE=0 4 SELECT=0 5 QUALITY=5 6 COPY_SS=0 7 SAVE_SS=0 8 NAME_SS="$(date '+%Y%m%d-%H%M%S').png" 9 SAVE_SS_DIR="$HOME/Pictures/Screenshots" 10 11 while getopts :wscxt:q:n:p: flag; do 12 case "${flag}" in 13 w) ACTIVE=1;; 14 s) SELECT=1;; 15 c) COPY_SS=1;; 16 x) SAVE_SS=1;; 17 t) TIMER=${OPTARG};; 18 q) QUALITY=${OPTARG};; 19 n) NAME_SS=${OPTARG};; 20 p) SAVE_SS_DIR=${OPTARG};; 21 *) echo "usage: $0 [-wxsc] [-t time(s)] [-q quality(1-10)] [-n name.png] [-p path/to/picture]"; exit 2 ;; 22 esac 23 done 24 25 [ $SAVE_SS -eq 0 ] && [ $COPY_SS -eq 0 ] && COPY_SS=1 26 [ $SAVE_SS -eq 1 ] && [ ! -d "${SAVE_SS_DIR}" ] && mkdir -p "${SAVE_SS_DIR}" 27 if [ $SELECT -eq 1 ]; then 28 TAGS="-s" 29 elif [ $ACTIVE -eq 1 ]; then 30 TAGS="-i $(xdotool getactivewindow)" 31 fi 32 33 sleep "$TIMER" 34 35 maim $TAGS -m "$QUALITY" "${SAVE_SS_DIR}/${NAME_SS}" || exit 2 36 37 if [ $SAVE_SS -eq 1 ] && [ $COPY_SS -eq 1 ]; then 38 xclip -selection clipboard -target image/png -i "${SAVE_SS_DIR}/${NAME_SS}" 39 SHOW="$(echo "${SAVE_SS_DIR}" | sed -e "s|${HOME}|~|g")/${NAME_SS} (+CLIPBOARD)" 40 elif [ $SAVE_SS -eq 0 ] && [ $COPY_SS -eq 1 ]; then 41 rm "${SAVE_SS_DIR}/${NAME_SS}" 42 SHOW="CLIPBOARD" 43 elif [ $SAVE_SS -eq 1 ] && [ $COPY_SS -eq 0 ]; then 44 SHOW="$(echo "${SAVE_SS_DIR}" | sed -e "s|${HOME}|~|g")/${NAME_SS}" 45 fi 46 47 NOTIF_MSG=" Picture acquired! 48 $SHOW" 49 50 notify "$NOTIF_MSG"