summaryrefslogtreecommitdiff
path: root/scripts/dmenu-screenshot
blob: d2fbbf7d486a50056ffe2b46b74eb93a90a85170 (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
38
39
40
41
42
#!/bin/sh

# Screenshot utility; if xclip is installed, it copies it to clipboard.
# Requires: dmenu (or similar), imagemagick, xclip (optional)

# Usage: dmenu-screenshot [-m menu]

usage() {
	echo "Usage: dmenu-screenshot [-m MENU]"
}

menu="dmenu -i"
prompt="Select type of screenshot:"

while getopts "m:" opt; do
	case "$opt" in
		m)
			menu="$OPTARG"
			;;
		*)
			usage
			exit 1
			;;
	esac
done
shift $((OPTIND - 1))

folder="$HOME/box/pictures/screenshots"
filename="screenshot_$(date +%Y-%m-%d-%H%M%S).png"
filepath="${folder}/${filename}"

t=$(printf 'Full\nSelection\n' | $menu -p "$prompt")
if [ "$t" = "Full" ]; then
	op="-window root"
else
	pkill xbanish # otherwise I can't use mouse to select area
fi

[ -n "$t" ] && sleep 0.1 && import $op "$filepath"
if command -v xclip >/dev/null 2>&1; then
	xclip -selection clipboard -t image/png < "$filepath"
fi

Generated with cgit - Back to sebastiano.tronto.net