This repository has been archived by the owner on Apr 6, 2023. It is now read-only.
forked from whats-this/owo.sh
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsetup.sh
executable file
·82 lines (66 loc) · 2.5 KB
/
setup.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/bin/bash
# _ _
# | | | |
# _____ _____ _ _ _ __ | | ___ __ _ __| | ___ _ __
# / _ \ \ /\ / / _ \ | | | | '_ \| |/ _ \ / _` |/ _` |/ _ \ '__|
# |(_) \ V V / (_)| | |_| | |_) | | (_) | (_| | (_| | __/ |
# \___/ \_/\_/ \___/ \__,_| .__/|_|\___/ \__,_|\__,_|\___|_|
# | |
# |_|
#
# OWO.SH SCRIPT.
# ----------------------
#
# This script is designed for you to be able to run the
# "owo file.png" command from anywhere in your terminal
# client and for it to work.
##################################
if [ ! $(id -u) -ne 0 ]; then
echo "ERROR : This script cannot be run as sudo."
echo "ERROR : You need to remove the sudo from \"sudo ./setup.sh\"."
exit 1
fi
##################################
if [ "${1}" = "--uninstall" ]; then
rm /usr/local/bin/owo
echo "INFO : Uninstallation of owo.sh finished!"
echo "INFO : However APT packages have not been removed."
exit 0
fi
##################################
function is_mac() {
uname | grep -q "Darwin"
}
if is_mac; then
scriptdir=$(dirname $(greadlink -f $0))
else
scriptdir=$(dirname $(readlink -f $0))
fi
owodir="$HOME/.config/owo"
if [ -d $owodir ]; then
cp $owodir/conf.cfg $owodir/conf.cfg.bak
fi
if [ ! -d $owodir ]; then
mkdir -p $owodir
sudo chown -R $USER:$USER $owodir
fi
cp -r $scriptdir/* $owodir
# Give directory ownership to the actual user
chown -R $(whoami | awk '{print $1}') $owodir
# Create a symbolic link to /usr/local/bin
if [ ! -f /usr/local/bin/owo ]; then
sudo ln -s $owodir/script.sh /usr/local/bin/owo
fi
# Install dependencies
if is_mac; then
echo "INFO : Dependencies are unavailable for Mac."
echo "INFO : Please run \"owo --check\" to check later on."
else
(which notify-send &>/dev/null && echo "FOUND : found notify-send") || echo "Notify-send not found. Please install it via your package manager." && exit 1
(which maim &>/dev/null && echo "FOUND : found maim") || echo "Maim not found. Please install it via your package manager." && exit 1
(which xclip &>/dev/null && echo "FOUND : found xclip") || echo "Xclip not found. Please install it via your package manager." && exit 1
(which slop &>/dev/null && echo "FOUND : found scrot") || echo "Slop not found. Please install via your package manager." && exit 1
fi
# Tell the user its done!
echo "INFO : Installation finished of owo.sh. Use it like \"owo file.png\""
echo "The config is in ~/.config/owo"