all repos — dotfiles @ 9d4daac1b851d9a89b0a429277c3d4d64331812d

my *nix dotfiles

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"