~skiqqy/bin

bin/picbin -rwxr-xr-x 775 bytes
c3280652Stephen Cochrane Added sandbox script 6 days ago
                                                                                
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
#!/bin/bash
# @Auther Stephen Cochrane
set -e

usage () {
	echo "<usage> picbin /path/to/picture"
	exit $1
}

area=0
while getopts "hp:la" opt
do
	case $opt in
		h)
			usage 0
			;;
		p)
			path="$OPTARG"
			;;
		l)
			link=1
			;;
		a)
			area=1
			;;
		*)
			exit 2
			;;
	esac
done

if [ $path ]
then
	[ 0 -eq $# ] && usage 1
	[[ ! -f $path ]] && usage 1
else
	if [[ area -eq 0 ]]
	then
		gnome-screenshot -f /tmp/picbin.png
	else
		gnome-screenshot -a -f /tmp/picbin.png
	fi
	path="/tmp/picbin.png"
fi

abort() {
	echo "Aborting upload of $path"
	exit 0
}

zenity --question --text="Confirm upload."
[ ! $? ] && abort

echo "Uploading -> $path"

url=$(curl -F"file=@$path" https://0x0.st)
echo $url
[ $link ] && zenity --info --window-icon="info" --text="$url" || exit 0