all repos — dotfiles @ d691874642b38e38d029d0251976f10a49f795fa

my *nix dotfiles

home/bin/scr (view raw)

 1#!/usr/bin/env bash
 2# scr: screenshot tool
 3
 4scr_path=~/pics/scrots
 5output="$(tr -dc 'a-zA-Z0-9' < /dev/random | fold -w 5 | head -n 1)"
 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            ;;
25        s)
26	        import "$scr_path/$output.png"
27            ;;
28        * | ?)
29            usage
30            exit;;
31        esac
32done
33
34if [ $OPTIND -eq 1 ]; then
35    echo "scr: missing argument"
36    usage
37    exit
38fi
39
40
41xclip -selection clipboard -t image/png -i "$scr_path/$output.png"
42cp "$scr_path/$output.png" "$scr_path/latest.png"