This repository has been archived by the owner on Apr 6, 2023. It is now read-only.
forked from whats-this/owo.sh
/
owo-gui.sh
65 lines (62 loc) · 1.96 KB
/
owo-gui.sh
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
#!/bin/bash
if [ ! $(id -u) -ne 0 ]; then
zenity --error --text="This script cannot be run as sudo."
exit 1
fi
ans=$(zenity --list --text "Choose your action" --radiolist --column "Pick" --column "Choice" FALSE Upload FALSE Screenshot FALSE Shorten)
echo $ans
if [[ $? -eq 1 ]]; then
exit 0
fi
if [[ $ans = "Screenshot" ]]; then
owo -s
if [[ $? -eq 3 ]]; then
zenity --error --text="Please put a key in ~/.config/owo/conf.cfg"
exit 1
fi
if [[ $? -eq 1 ]]; then
zenity --error --text="An unexpected error has occured. Please consult ~/.config/owo/log.txt for details."
exit 1
fi
zenity --info --text="Upload Complete. URL copied to clipboard."
exit 0
elif [[ $ans = "Upload" ]]; then
FILE=`zenity --file-selection --title="Select a File to Upload"`
case $? in
0)
zenity --info --text="\"$FILE\" selected.";;
1)
zenity --error --text="No file selected." && exit;;
-1)
zenity --error --text="An unexpected error has occurred." && exit 1;;
esac
sleep 2
owo $FILE
if [[ $? -eq 3 ]]; then
zenity --error --text="Please put a key in ~/.config/owo/conf.cfg"
exit 1
fi
if [[ $? -eq 1 ]]; then
zenity --error --text="An unexpected error has occured. Please consult ~/.config/owo/log.txt for details."
exit 1
fi
zenity --info --text="Upload Complete. URL copied to clipboard."
exit 0
elif [[ $ans = "Shorten" ]]; then
s_url=`zenity --entry --title="Enter URL" --text="Please enter the URL you wish to shorten."`
owo -l $s_url
if [[ $s_url = "" ]]; then
zenity --error --text="URL not found!"
exit 1
fi
if [[ $? -eq 3 ]]; then
zenity --error --text="Please put a key in ~/.config/owo/conf.cfg"
exit 1
fi
if [[ $? -eq 1 ]]; then
zenity --error --text="An unexpected error has occured. Please consult ~/.config/owo/log.txt for details."
exit 1
fi
zenity --info --text="Upload Complete. URL copied to clipboard."
exit 0
fi