aboutsummaryrefslogtreecommitdiff
path: root/local/bin/screenshot-prompt
blob: f88989a52d7af712847cd95661cad1be44a1528f (plain)
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
#!/bin/sh

set -e

command -v scrot > /dev/null ||
	{ echo "scrot not installed" ; exit 1 ; }
command -v rofi > /dev/null &&
    menu_exec='rofi -dmenu' ||
    menu_exec='dmenu'

choice="$(
$menu_exec <<EOF
Crop to file
Crop to clipboard
Fullscreen to file
Fullscreen to clipboard
EOF
)"

screenshot_dir="$HOME/screenshots"
[ ! -d "$screenshot_dir" ] && mkdir "$screenshot_dir"
file_format="$screenshot_dir/"'%Y-%m-%d_$wx$h.png'

case "$choice" in
    'Crop to file')
        scrot --select --silent --file "$file_format"
        ;;
    'Crop to clipboard')
        scrot --select --silent - | xclip -selection clipboard -target image/png
        ;;
    'Fullscreen to file')
        scrot --silent --file "$file_format"
        ;;
    'Fullscreen to clipboard')
        scrot --silent - | xclip -selection clipboard -target image/png
        ;;
esac