This repository was archived by the owner on Dec 20, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathklibbert
More file actions
executable file
·93 lines (85 loc) · 1.82 KB
/
klibbert
File metadata and controls
executable file
·93 lines (85 loc) · 1.82 KB
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
#!/bin/bash
# Klibbert v1.2.1
# Written by Simon Sinding - 2016 Github.com/TheSinding/
SCREENSHOT_DIR="$HOME/screenshots/"
SCROT_FILE_OPTIONS="%Y-%m-%d_\$wx\$h_scrot.png"
FILENAME=""
DEFAULT_FILENAME=$(date +%F-%T)
DEFAULT_FILEFORMAT="png"
DEFAULT_SERVICE="https://ptpb.pw/"
TITLE="Klibbert"
hash maim 2>/dev/null ||
{
echo >&2 "Error: Maim is required but it's not installed. Aborting.";
exit 1;
}
hash slop 2>/dev/null ||
{
echo >&2 "Warning: For -r to work, slop is required but it's not installed.";
NO_R=true
}
if [ ! -d $SCREENSHOT_DIR ]; then
echo "Info: $HOME/screenshots/ does not exists, creating it!"
mkdir $SCREENSHOT_DIR
fi
MESSAGE(){
echo $*
if [ -n `which notify-send` ]; then
notify-send "$TITLE" "$*"
fi
}
HELP(){
echo "Written by Simon Sinding - 2016 - Github.com/TheSinding/"
echo "Klibbert v1.2.1"
echo "Usage: klibbert [OPTIONS]"
echo " -h, Shows this help"
echo " -f, Fullscreen screenshot"
echo " -r, Region screenshot"
exit 1
}
OPEN(){
if [ $1 ]; then
xdg-open $1
fi
exit 1
}
CREATE_FILENAME(){
FILENAME="$SCREENSHOT_DIR$DEFAULT_FILENAME.$DEFAULT_FILEFORMAT"
}
UPLOAD(){
RETURN=$(curl -F c=@- $DEFAULT_SERVICE < $1 2>&1)
URL=$(echo "$RETURN" | sed -n -e 's/^\(url: \)\(.*\)$/\2/p' 2>&1)
MESSAGE "Success: picture will open in default browser"
OPEN $URL
}
while getopts ":frh" opt; do
case $opt in
h)
HELP
;;
f)
CREATE_FILENAME
maim $FILENAME
MESSAGE "Uploading screenshot!"
UPLOAD $FILENAME
;;
r)
if [ ! $NO_SLOP ]; then
CREATE_FILENAME
maim -s $FILENAME
MESSAGE "Uploading screenshot!"
UPLOAD $FILENAME
else
echo "-$OPTARG needs slop. You'll have to install it"
exit 1
fi
;;
\?)
echo "Error: -$OPTARG is an invalid option"
HELP
;;
esac
done
if (($# == 0)); then
HELP
fi