-
Notifications
You must be signed in to change notification settings - Fork 0
/
discord-manager
64 lines (58 loc) · 1.82 KB
/
discord-manager
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
#!/usr/bin/env bash
# GitHub: https://github.com/hafiz-muhammad
# tput colors
RED="$(tput bold setaf 1)"
GREEN="$(tput bold setaf 2)"
BLUE="$(tput bold setaf 4)"
MAGENTA="$(tput setaf 5)"
RESET="$(tput sgr0)"
menu() {
# Display menu options in color and prompts the user for input.
echo -ne "
${GREEN}1)${RESET} ${BLUE}Install/Update Discord${RESET}
${GREEN}2)${RESET} ${BLUE}Uninstall Discord${RESET}
${GREEN}3)${RESET} ${BLUE}Clear Discord Cache${RESET}
${GREEN}4)${RESET} ${RED}Exit${RESET}
${MAGENTA}\nSelect an option (1-4):${RESET} "
read opts
# Check for invalid user input and returns to menu.
if ! [[ $opts =~ ^[1-4]$ ]]; then
echo "${RED}Invalid option.${RESET}"
menu
return
fi
case $opts in
"1")
# Install/Update Discord
cd ~/Downloads
wget -O discord.tar.gz "https://discord.com/api/download?platform=linux&format=tar.gz"
sudo tar -xvzf discord.tar.gz -C /opt
sudo ln -sf /opt/Discord/Discord /usr/bin/Discord
sudo cp -r /opt/Discord/discord.desktop /usr/share/applications
sudo sed -i 's*Exec=/usr/share/discord/Discord*Exec=/usr/bin/Discord*g' /usr/share/applications/discord.desktop
sudo sed -i 's*Icon=discord*Icon=/opt/Discord/discord.png*g' /usr/share/applications/discord.desktop
rm -rf ~/Downloads/discord.tar.gz
exec "$0"
;;
"2")
# Uninstall Discord
rm -rf ~/.config/discord
sudo rm -rf /opt/Discord
sudo rm -rf /usr/bin/Discord
sudo rm -rf /usr/share/applications/discord.desktop
exec "$0"
;;
"3")
# Clear Discord cache
rm -rf ~/.config/discord/Cache
rm -rf ~/.config/discord/Code\ Cache
rm -rf ~/.config/discord/GPUCache
exec "$0"
;;
"4")
# Exit the script
exit
;;
esac
}
menu