bin/scr (view raw)
1#!/usr/bin/env bash
2# scr: screenshot tool
3
4scr_path=~/pics/scrots
5n=6; output=$(tr -cd '[:alnum:]' < /dev/urandom | head -c$n)
6
7usage() {
8 echo "usage:"
9 echo " scr [option]"
10 echo "options:"
11 echo " -f full screenshot"
12 echo " -w window screenshot"
13 echo " -s selection screenshot"
14}
15
16while getopts fws option
17do
18 case $option in
19 f)
20 import -window root "$scr_path/$output.png"
21 notify-send "screenshot taken!"
22 ;;
23 w)
24 import -window "$(xdotool getwindowfocus)" "$scr_path/$output.png"
25 convert "$scr_path/$output.png" \( +clone -background transparent -shadow 60x40+0+15 \) \
26 +swap -background white -layers merge +repage "$scr_path/$output.png"
27 notify-send "window screenshot taken!"
28 ;;
29 s)
30 g=$(slop --highlight --tolerance=0 --color=0.3,0.4,0.6,0.4)
31 sleep 1
32 import -window root -crop "$g" +repage "$scr_path/$output.png"
33 notify-send "selection screenshot taken!"
34 ;;
35 * | ?)
36 usage
37 exit;;
38 esac
39done
40
41if [ $OPTIND -eq 1 ]; then
42 echo "scr: missing argument"
43 usage
44 exit
45fi
46
47
48xclip -selection clipboard -t image/png -i "$scr_path/$output.png"