blob: b610f79d61da854a3f4457057db81ef6f8a62970 (
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
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
|
#!/usr/bin/env sh
# Dependences:
# xclip
# imagemagick
# dmenu
# scrot
#
# TODO:
# - integrate https://img.vim-cn.com/, an image pastebin
NC='\033[0m'
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
msg_info() {
echo -e "${GREEN}$1${NC}"
}
msg_warn() {
echo -e "${YELLOW}$1${NC}"
}
msg_error() {
echo -e "${RED}$1${NC}"
}
print_help() {
echo
echo "screenshot - a wrapper for scrot (screenshot utility)"
echo
echo "USAGE:"
echo " screenshot [OPTION ...]"
echo
echo "OPTIONs are:"
echo " -s | --selection:"
echo " takes a screenshot of the selected area or window (equivalent"
echo " to scrot selection feature)."
echo " -c | --clipboard:"
echo " copy the screenshot to the system clipboard."
echo " -d | --dmenu:"
echo " Use dmenu to interactively choose whether to use the selection"
echo " and copy-to-clipboard features."
echo " -z | --silent:"
echo " Turn off notifications (scrot sound notification is always off)."
echo " -h | -? | --help:"
echo " print this help."
echo
}
notify() {
convert "$1" -resize 200x200 "$2"
notify-send --expire-time=5000 --icon="$2" "Screenshot taken." "$1"
}
copy_to_clipboard() {
cat "$1" | xclip -selection clipboard -t image/png
}
command=${1:-simple}
shift
case $command in
simple)
# Just take a screenshot
;;
ls|list)
;;
start)
;;
stop)
;;
add)
;;
rm|remove)
;;
del|delete)
;;
pause)
;;
unpause)
;;
info)
;;
help)
print_help
;;
*)
msg_error "$COMMAND: invalid command"
print_help
exit 1
;;
esac
name="screenshot-$(date '+%Y%m%d-%H%M%S').png"
scrot_path="$IMGS/screenshots/"
thumb_path="$TMPDIR/screenshots/"
choice=$(echo -e "select\nselect and copy\nfullscreen\nfullscreen and copy" | dmenu -l 10 -i -p "Screenshot:")
mkdir -p "$scrot_path"
mkdir -p "$thumb_path"
case "$choice" in
"select")
scrot -s "$scrot_path$name"
notify "$scrot_path$name" "$thumb_path$name"
;;
"select and copy")
scrot -s "$scrot_path$name"
notify "$scrot_path$name" "$thumb_path$name"
copy_to_clipboard "$scrot_path$name"
;;
"fullscreen")
scrot "$scrot_path$name"
notify "$scrot_path$name" "$thumb_path$name"
;;
"fullscreen and copy")
scrot "$scrot_path$name"
notify "$scrot_path$name" "$thumb_path$name"
copy_to_clipboard "$scrot_path$name"
;;
*)
exit 1
;;
esac
#
#
#exit 0
|