blob: 2a23d972a480d85c4d3c7772dbbc9d6bf8a1161c (
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
|
#!/bin/sh
if ! type xdg-user-dir; then
notify-send "xdg-user-dir is not installed" "Install it with your system package manager"
exit
fi
TYPE="$(printf "Window/Area\nScreen" | dmenu -i -p 'What do you want to screenshot?')"
[ -z "$TYPE" ] && exit
[ "$TYPE" = "Window/Area" ] && TIME_DEFAULT="0" || TIME_DEFAULT="1"
WHERE="$(printf "Copy\nSave" | dmenu -i -p 'Do you want to save or copy to clipboard?')"
[ -z "$WHERE" ] && exit
TIME="$(printf "%s\n5\n10\n15" "$TIME_DEFAULT" | dmenu -i -p 'How many seconds do you want to wait?')"
[ -z "$TIME" ] && exit
case "$TYPE" in
Window/Area) TYPE="-s -u";;
Screen) TYPE=""
esac
mkdir -p "$(xdg-user-dir PICTURES)"/Screenshot 2>/dev/null
sleep "$TIME"
# shellcheck disable=SC2086
case "$WHERE" in
Copy) maim $TYPE | xclip -selection clipboard -t image/png;;
Save) maim $TYPE "$(xdg-user-dir PICTURES)/Screenshot/$(date +%G-%m-%d_%s.png)"
esac
|