-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·113 lines (102 loc) · 2.92 KB
/
install.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
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
#!/usr/bin/env bash
usage() {
cat << EOF
Usage: Nautilus Application Adder [OPTION]...
OPTIONS:
-i, --install, Install Nautilus Application Adder, will kill
-r, --remove, Remove installed themes
-c, --clean, Clean this directory after install
-h, --help Show help
EOF
}
install() {
InstallDeps
mkdir -p ~/.local/share/nautilus-python/extensions/NautilusApplications
cp Extension/NautilusApplications.py ~/.local/share/nautilus-python/extensions/NautilusApplications
cp Extension/window.py ~/.local/share/nautilus-python/extensions/NautilusApplications
cp Extension/NautliusApplications-runner.py ~/.local/share/nautilus-python/extensions
ConfigFile="$HOME/.local/share/nautilus-python/extensions/NautilusApplications/config.json"
if [ -e $ConfigFile ]; then
echo "Config exists, removing"
rm $ConfigFile
fi
touch $ConfigFile
echo '{' >> $ConfigFile
echo ' "items": {' >> $ConfigFile
echo ' "_comment": "Items to include in the context menu",' >> $ConfigFile
echo ' "AddToLocal": true,' >> $ConfigFile
echo ' "RemoveFromLocal": true' >> $ConfigFile
echo ' }' >> $ConfigFile
echo '}' >> $ConfigFile
}
InstallDeps() {
# Install python-nautilus
echo "Installing python-nautilus..."
if type "pacman" > /dev/null 2>&1
then
# check if already install, else install
pacman -Qi python-nautilus &> /dev/null
if [ `echo $?` -eq 1 ]
then
sudo pacman -S --noconfirm python-nautilus
else
echo "python-nautilus is already installed"
fi
elif type "apt-get" > /dev/null 2>&1
then
# Find Ubuntu python-nautilus package
package_name="python-nautilus"
found_package=$(apt-cache search --names-only $package_name)
if [ -z "$found_package" ]
then
package_name="python3-nautilus"
fi
# Check if the package needs to be installed and install it
installed=$(apt list --installed $package_name -qq 2> /dev/null)
if [ -z "$installed" ]
then
sudo apt-get install -y $package_name
else
echo "$package_name is already installed."
fi
elif type "dnf" > /dev/null 2>&1
then
installed=`dnf list --installed nautilus-python 2> /dev/null`
if [ -z "$installed" ]
then
sudo dnf install -y nautilus-python
else
echo "nautilus-python is already installed."
fi
else
echo "Failed to find python-nautilus, please install it manually."
fi
}
remove() {
rm -r ~/.local/share/nautilus-python/extensions/NautilusApplications
rm ~/.local/share/nautilus-python/extensions/NautliusApplications-runner.py
}
VALID_ARGS=$(getopt -o hir --long help,install,remove -- "$@")
if [[ $? -ne 0 ]]; then
exit 1;
fi
eval set -- "$VALID_ARGS"
while [ : ]; do
case "$1" in
-h | --help)
usage
shift
;;
-i | --install)
install
shift
;;
-r | --remove)
remove
shift
;;
--) shift;
break
;;
esac
done