summaryrefslogtreecommitdiff
path: root/bin/screenshot
blob: 1cf96fd34ff5d3abcc62b976af267ae2e66f8e56 (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
#!/bin/sh

# Capture screen with maim.
#
# Either screenshot entire screen or manually select a region. Saves to a
# screenshots directory and optionally copies to clipboard.

command -v maim > /dev/null || exit 1

dir="$(xdg-user-dir PICTURES)/screenshots"
path="$dir/$(date '+%Y-%m-%dT%H:%M:%S').png"

if [ ! -d "$dir" ]; then
	mkdir "$dir"
fi

if [ "$1" = "region" ]; then
	args="-s -b 1 -c 0.92,0.86,0.70"
elif [ "$1" = "full" ]; then
	args=""
else
	echo "Usage: screenshot [region|full] <clipboard>"
	exit 1
fi

# shellcheck disable=SC2086
if [ "$2" = "clipboard" ]; then
	maim $args | tee "$path" | xclip -selection clipboard -t image/png
else
	maim $args "$path"
fi