-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathscreenshot
executable file
·69 lines (58 loc) · 1.12 KB
/
screenshot
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/usr/bin/env bash
#
# screenshot
#
# Simple screenshot wrapper around maim
#
# Author: Emanuel Duss
#
set -o errexit
set -o pipefail
APP="feh -g 600x600+50%+50% --borderless --scale-down --image-bg checks"
print_usage(){
cat << EOI
Usage: screenshot [OPTION] [FILE]
By default, the selection is saved to your home directory.
Options:
-f fullscreen screenshot
-c copy selection to clipboard
-h display this help and exit
File:
filename or directory where to save the screenshot.
EOI
}
check_dependencies(){
local FAIL=0
for tool in "$@"
do
if ! hash "$tool" &> /dev/null
then
echo "The tool $tool does not exist."
FAIL=1
fi
done
if [[ "$FAIL" == 1 ]]
then
exit 1
fi
}
main(){
check_dependencies maim
case $1 in
"full")
FILENAME="$HOME/$(date +%Y-%m-%d_%H-%M-%S).png"
maim "$FILENAME"
$APP "$FILENAME"
;;
"copy")
check_dependencies xclip
maim -s | xclip -selection clipboard -t image/png
;;
*)
FILENAME="$HOME/$(date +%Y-%m-%d_%H-%M-%S).png"
maim -s "$FILENAME"
$APP "$FILENAME"
;;
esac
}
main "$@"