blob: dff8701104cc30ba6eccffa8398c0510dc9002cd (
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
28
29
30
31
32
33
34
35
36
37
|
#!/bin/sh
img_path=~/Pictures/Screenshots/"$(date +%Y-%m-%d_%H-%m-%s)".png
current_screen() {
MONITORS=$(xrandr | grep -o '[0-9]*x[0-9]*[+-][0-9]*[+-][0-9]*')
for mon in ${MONITORS}; do
# Parse the geometry of the monitor
MONW=$(echo "${mon}" | awk -F "[x+]" '{print $1}')
MONH=$(echo "${mon}" | awk -F "[x+]" '{print $2}')
MONX=$(echo "${mon}" | awk -F "[x+]" '{print $3}')
MONY=$(echo "${mon}" | awk -F "[x+]" '{print $4}')
done
}
case $1 in
selected-region)
# Take a screenshot of the selected region
maim -s "${img_path}"
;;
selected-window)
# Take a screenshot of the selected window
maim -i $(xdotool getactivewindow) "${img_path}"
;;
save-to-clipboard)
# Take a screenshot and save it to the clipboard
current_screen
maim -g "${MONW}x${MONH}+${MONX}+${MONY}" | xclip -selection clipboard -t image/png
exit 0
;;
*)
# Take a screenshot of the currently focused output and save it into screenshots
current_screen
maim -g "${MONW}x${MONH}+${MONX}+${MONY}" "${img_path}"
exit 0
;;
esac
|