aboutsummaryrefslogtreecommitdiff
path: root/.local/bin/screenshot.sh
blob: 8276f6564c3be86f26f0dee72a902ddfe5fce271 (plain) (blame)
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
#!/bin/sh

# Get focused output
output="$(mmsg -g | grep "selmon 1" | awk '{print$1}')"

case $1 in
	selected-region)
		# Take a screenshot of the selected region
		grim -t jpeg -g "$(slurp)" ~/Pictures/Screenshots/"$(date +%Y-%m-%d_%H-%m-%s)".jpg
		;;
	save-to-clipboard)
		# Take a screenshot and save it to the clipboard
		grim -g "$(slurp -d)" - | wl-copy
		;;
	focused-window)
		# Take a screenshot of the focused window
		xpos=$(mmsg -o "$output" -x | grep "x" | awk '{print$2}')
		ypos=$(mmsg -o "$output" -x | grep "y" | awk '{print$2}')
		xsize=$(mmsg -o "$output" -x | grep "width" | awk '{print$2}')
		ysize=$(mmsg -o "$output" -x | grep "height" | awk '{print$2}')
		grim -g "$xpos"",""$ypos $xsize""x""$ysize" -t jpeg ~/Pictures/Screenshots/"$(date +%Y-%m-%d_%H-%m-%s)".jpg
		;;
		*)
		# Take a screenshot of the currently focused output and save it into screenshots
		grim -o "$output" -t jpeg ~/Pictures/Screenshots/"$(date +%Y-%m-%d_%H-%m-%s)".jpg
		;;
esac