-
Notifications
You must be signed in to change notification settings - Fork 25
/
installer.sh
executable file
·86 lines (74 loc) · 2.35 KB
/
installer.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
#!/bin/bash
do_installation() {
echo "Installing Findex..."
echo "Building Findex..."
cargo build --release
if [[ $? -ne 0 ]]; then
echo "Findex failed to build."
exit 1
fi
echo "Copying files..."
sudo cp target/release/findex /usr/bin/findex
sudo cp target/release/findex-daemon /usr/bin/findex-daemon
sudo echo ""
sudo mkdir -p /opt/findex
sudo cp css/style.css /opt/findex
sudo install -Dm644 service/*.service -t /usr/lib/systemd/user
systemctl daemon-reload --user
if [[ ! -f ~/.config/findex/settings.toml ]]; then
touch ~/.config/findex/settings.toml
fi
if [[ ! -f ~/.config/findex/style.css ]]; then
cp css/style.css ~/.config/findex/style.css
fi
echo "Installation done!"
echo "Now add \"findex-daemon\" to autostart. You may follow your desktop environment's guide to do this."
echo "I'm starting \"findex-daemon\" for now."
findex-daemon
echo "Findex can't bind hotkey in wayland."
echo "To bind hotkey, bind the following command to your desired hotkey in the desktop environment you are using"
echo "echo 1 > ~/.config/findex/toggle_file"
echo "If you had Findex 0.6.0 installed, you may want to remove findex services from systemd."
}
do_removal() {
echo "Removing files..."
sudo rm /usr/bin/findex
sudo rm /usr/bin/findex-daemon
sudo rm -r /opt/findex
killall findex-daemon findex
systemctl stop --user findex-daemon.service
systemctl disable --user findex-daemon.service
sudo rm -f /usr/lib/systemd/user/findex-daemon.service
systemctl daemon-reload --user
echo "Removal done!"
echo "If you added \"findex-daemon\" to autostart, you may remove it now."
}
prompt_for_installation() {
while true; do
read -r -p "Install findex? [Y/N] " yn
case $yn in
[Yy]*)
do_installation
break
;;
[Nn]*) break ;;
esac
done
}
main() {
if test -f "/usr/bin/findex"; then
while true; do
read -r -p "Found existing installation. Do you want to uninstall it? [Y/N] " yn
case $yn in
[Yy]*)
do_removal
prompt_for_installation
exit
;;
[Nn]*) exit ;;
esac
done
fi
do_installation
}
main