all repos — dotfiles @ 7b11a72879acfe5c41286ca9dbb0533ad8643898

my *nix dotfiles

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            ;;
22        w)
23            import -window "$(xdotool getwindowfocus)" "$scr_path/$output.png"
24            convert "$scr_path/$output.png" \( +clone -background transparent -shadow 60x40+0+15 \) \
25	        +swap -background white -layers merge +repage "$scr_path/$output.png"
26            ;;
27        s)
28            g=$(slop --highlight --tolerance=0 --color=0.3,0.4,0.6,0.4)
29	        sleep 1
30	        import -window root -crop "$g" +repage "$scr_path/$output.png"
31            ;;
32        * | ?)
33            usage
34            exit;;
35        esac
36done
37
38if [ $OPTIND -eq 1 ]; then
39    echo "scr: missing argument"
40    usage
41    exit
42fi
43
44
45xclip -selection clipboard -t image/png -i "$scr_path/$output.png"