-
-
Notifications
You must be signed in to change notification settings - Fork 92
/
Copy pathuninstall.sh
executable file
·281 lines (251 loc) · 9.79 KB
/
uninstall.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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
#!/bin/bash
# 💫 https://github.com/JaKooLit 💫 #
# KooL Fedora-Hyprland uninstall script #
clear
# Set some colors for output messages
OK="$(tput setaf 2)[OK]$(tput sgr0)"
ERROR="$(tput setaf 1)[ERROR]$(tput sgr0)"
NOTE="$(tput setaf 3)[NOTE]$(tput sgr0)"
INFO="$(tput setaf 4)[INFO]$(tput sgr0)"
WARN="$(tput setaf 1)[WARN]$(tput sgr0)"
CAT="$(tput setaf 6)[ACTION]$(tput sgr0)"
MAGENTA="$(tput setaf 5)"
ORANGE="$(tput setaf 214)"
WARNING="$(tput setaf 1)"
YELLOW="$(tput setaf 3)"
GREEN="$(tput setaf 2)"
BLUE="$(tput setaf 4)"
SKY_BLUE="$(tput setaf 6)"
RESET="$(tput sgr0)"
printf "\n%.0s" {1..2}
echo -e "\e[35m
╦╔═┌─┐┌─┐╦ ╦ ╦┬ ┬┌─┐┬─┐┬ ┌─┐┌┐┌┌┬┐
╠╩╗│ ││ │║ ╠═╣└┬┘├─┘├┬┘│ ├─┤│││ ││ UNINSTALL
╩ ╩└─┘└─┘╩═╝ ╩ ╩ ┴ ┴ ┴└─┴─┘┴ ┴┘└┘─┴┘ Fedora Linux
\e[0m"
printf "\n%.0s" {1..1}
# Welcome Message
whiptail --title "Fedora-Hyprland KooL Dots Uninstall Script" --yesno \
"Hello! This script will uninstall KooL Hyprland packages and configs.
You can choose packages and directories you want to remove.
NOTE: This will remove configs from ~/.config
WARNING: After uninstallation, your system may become unstable.
Shall we Proceed?" 20 80
if [ $? -eq 1 ]; then
echo "$INFO uninstall process canceled."
exit 0
fi
# Function to remove selected packages on Fedora
remove_packages() {
local selected_packages_file=$1
while read -r package; do
# Check if the package is installed using dnf
if dnf list installed "$package" &> /dev/null; then
echo "Removing package: $package"
if ! sudo dnf remove -y "$package"; then
echo "$ERROR Failed to remove package: $package"
else
echo "$OK Successfully removed package: $package"
fi
else
echo "$INFO Package ${YELLOW}$package${RESET} not found. Skipping."
fi
done < "$selected_packages_file"
}
# Function to remove selected directories
remove_directories() {
local selected_dirs_file=$1
while read -r dir; do
pattern="$HOME/.config/$dir*"
# Loop through directories matching the pattern
for dir_to_remove in $pattern; do
if [ -d "$dir_to_remove" ]; then
echo "Removing directory: $dir_to_remove"
if ! rm -rf "$dir_to_remove"; then
echo "$ERROR Failed to remove directory: $dir_to_remove"
else
echo "$OK Successfully removed directory: $dir_to_remove"
fi
else
echo "$INFO Directory ${YELLOW}$dir_to_remove${RESET} not found. Skipping."
fi
done
done < "$selected_dirs_file"
}
# Function to safely remove COPR repositories
remove_copr() {
for repo in "$@"; do
if sudo dnf copr list | grep -q "$repo"; then
sudo dnf copr remove -y "$repo"
else
# Print message in yellow when the repository is not enabled
echo -e "${YELLOW}COPR repository $repo is not enabled, skipping.${RESET}"
fi
done
}
# Define the list of packages to choose from (with options_command tags)
packages=(
"btop" "resource monitor" "off"
"brightnessctl" "brightnessctl" "off"
"cava" "Cross-platform Audio Visualizer" "off"
"cliphist" "clipboard manager" "off"
"fastfetch" "fastfetch" "off"
"ffmpegthumbnailer" "FFmpeg Thumbnailer" "off"
"grim" "screenshot tool" "off"
"ImageMagick" "Image manipulation tool" "off"
"kitty" "kitty-terminal" "off"
"kvantum" "QT apps theming" "off"
"mousepad" "simple text editor" "off"
"mpv" "multi-media player" "off"
"mpv-mpris" "mpv-plugin" "off"
"network-manager-applet" "network-manager-applet" "off"
"nvtop" "gpu resource monitor" "off"
"nwg-displays" "display monitor configuration app" "off"
"nwg-look" "gtk settings app" "off"
"pamixer" "pamixer" "off"
"pavucontrol" "pavucontrol" "off"
"playerctl" "playerctl" "off"
"pyprland" "pyprland" "off"
"qalculate-gtk" "calculater - QT" "off"
"qt5ct" "qt5ct" "off"
"qt6ct" "qt6ct" "off"
"rofi-wayland" "rofi-wayland" "off"
"slurp" "screenshot tool" "off"
"swappy" "screenshot tool" "off"
"SwayNotificationCenter" "notification agent" "off"
"swww" "wallpaper engine" "off"
"Thunar" "File Manager" "off"
"thunar-archive-plugin" "Archive Plugin" "off"
"thunar-volman" "Volume Management" "off"
"tumbler" "Thumbnail Service" "off"
"wallust" "color pallete generator" "off"
"waybar" "wayland bar" "off"
"wl-clipboard" "clipboard manager" "off"
"wlogout" "logout menu" "off"
"xdg-desktop-portal-hyprland" "hyprland file picker" "off"
"yad" "dialog box" "off"
"yt-dlp" "video downloader" "off"
"xarchiver" "Archive Manager" "off"
"hypridle" "hyprland idling agent" "off"
"hyprlock" "lockscreen" "off"
"hyprpolkitagent" "hyprland polkit agent" "off"
"hyprland" "hyprland main package" "off"
)
# Define the list of directories to choose from (with options_command tags)
directories=(
"ags" "AGS desktop overview configuration" "off"
"btop" "btop configuration" "off"
"cava" "cava configuration" "off"
"fastfetch" "fastfetch configuration" "off"
"hypr" "main hyprland configuration" "off"
"kitty" "kitty terminal configuration" "off"
"Kvantum" "Kvantum-manager configuration" "off"
"qt5ct" "qt5ct configuration" "off"
"qt6ct" "qt6ct configuration" "off"
"rofi" "rofi configuration" "off"
"swappy" "swappy (screenshot tool) configuration" "off"
"swaync" "swaync (notification agent) configuration" "off"
"Thunar" "Thunar file manager configuration" "off"
"wallust" "wallust (color pallete) configuration" "off"
"waybar" "waybar configuration" "off"
"wlogout" "wlogout (logout menu) configuration" "off"
)
# Loop for package selection until user selects something or cancels
while true; do
package_choices=$(whiptail --title "Select Packages to Uninstall" --checklist \
"Select the packages you want to remove\nNOTE: 'SPACEBAR' to select & 'TAB' key to change selection" 35 90 25 \
"${packages[@]}" 3>&1 1>&2 2>&3)
# Check if the user canceled the operation
if [ $? -eq 1 ]; then
echo "$INFO uninstall process canceled."
exit 0
fi
# If no packages are selected, ask again
if [[ -z "$package_choices" ]]; then
echo "$NOTE No packages selected. Please select at least one package."
else
echo "$package_choices" | tr -d '"' | tr ' ' '\n' > /tmp/selected_packages.txt
echo "Packages to remove: $package_choices"
break
fi
done
# Loop for directory selection until user selects something or cancels
while true; do
dir_choices=$(whiptail --title "Select Directories to Remove" --checklist \
"Select the directories you want to remove\nNOTE: This will remove configs from ~/.config\n\nNOTE: 'SPACEBAR' to select & 'TAB' key to change selection" 28 90 18 \
"${directories[@]}" 3>&1 1>&2 2>&3)
# Check if the user canceled the operation
if [ $? -eq 1 ]; then
echo "$INFO uninstall process canceled."
exit 0
fi
# If no directories are selected, ask again
if [[ -z "$dir_choices" ]]; then
echo "$NOTE No directories selected. Please select at least one directory."
else
# Save each selected directory to a new line in the temporary file
echo "$dir_choices" | tr -d '"' | tr ' ' '\n' > /tmp/selected_directories.txt
echo "Directories to remove: $dir_choices"
break
fi
done
# First confirmation - Warning about potential instability
if ! whiptail --title "Warning" --yesno \
"Warning: Removing these packages and directories may cause your system to become unstable and you may not be able to recover it.\n\nAre you sure you want to proceed?" \
10 80; then
echo "$INFO uninstall process canceled."
exit 0
fi
# Second confirmation - Final confirmation to proceed
if ! whiptail --title "Final Confirmation" --yesno \
"Are you absolutely sure you want to remove the selected packages and directories?\n\nWARNING! This action is irreversible." \
10 80; then
echo "$INFO uninstall process canceled."
exit 0
fi
printf "\n%.0s" {1..1}
printf "\n%s${SKY_BLUE}Attempting to remove selected packages${RESET}\n" "${NOTE}"
MAX_ATTEMPTS=2
ATTEMPT=0
while [ $ATTEMPT -lt $MAX_ATTEMPTS ]; do
# Remove packages
remove_packages /tmp/selected_packages.txt
# Check if any packages still need to be removed, retry if needed
MISSING_PACKAGE_COUNT=0
while read -r package; do
if dnf list installed "$package" &> /dev/null; then
MISSING_PACKAGE_COUNT=$((MISSING_PACKAGE_COUNT + 1))
fi
done < /tmp/selected_packages.txt
if [ $MISSING_PACKAGE_COUNT -gt 0 ]; then
ATTEMPT=$((ATTEMPT + 1))
echo "Attempt #$ATTEMPT failed, retrying..."
else
break
fi
done
printf "\n%.0s" {1..1}
printf "\n%s${SKY_BLUE}Attempting to remove locally installed packages${RESET}\n" "${NOTE}"
for file in ags; do
if [ -f "/usr/local/bin/$file" ]; then
sudo rm "/usr/local/bin/$file"
echo "$file removed."
fi
done
printf "\n%.0s" {1..1}
printf "\n%s${SKY_BLUE}Attempting to remove selected directories${RESET}\n" "${NOTE}"
remove_directories /tmp/selected_directories.txt
# Remove COPR repositories
printf "\n%.0s" {1..1}
printf "\n%s ${INFO} Removing COPR repositories..."
COPR_REPOS=(
solopasha/hyprland
erikreider/SwayNotificationCenter
errornointernet/packages
tofik/nwg-shell
)
remove_copr "${COPR_REPOS[@]}"
printf "\n%.0s" {1..1}
echo -e "$MAGENTA Hyprland and related components have been uninstalled.$RESET"
echo -e "$YELLOW It is recommended to reboot your system now.$RESET"
printf "\n%.0s" {1..1}