all repos — dotfiles @ 7b11a72879acfe5c41286ca9dbb0533ad8643898

my *nix dotfiles

bin/scr (view raw)

 1
 2
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
#!/usr/bin/env bash
# scr: screenshot tool

scr_path=~/pics/scrots
n=6; output=$(tr -cd '[:alnum:]' < /dev/urandom | head -c$n)

usage() {
    echo "usage:"
    echo "  scr [option]"
    echo "options:"
    echo "  -f    full screenshot"
    echo "  -w    window screenshot"
    echo "  -s    selection screenshot"
}

while getopts fws option
do
    case $option in
        f)
            import -window root "$scr_path/$output.png"
            ;;
        w)
            import -window "$(xdotool getwindowfocus)" "$scr_path/$output.png"
            convert "$scr_path/$output.png" \( +clone -background transparent -shadow 60x40+0+15 \) \
	        +swap -background white -layers merge +repage "$scr_path/$output.png"
            ;;
        s)
            g=$(slop --highlight --tolerance=0 --color=0.3,0.4,0.6,0.4)
	        sleep 1
	        import -window root -crop "$g" +repage "$scr_path/$output.png"
            ;;
        * | ?)
            usage
            exit;;
        esac
done

if [ $OPTIND -eq 1 ]; then
    echo "scr: missing argument"
    usage
    exit
fi


xclip -selection clipboard -t image/png -i "$scr_path/$output.png"