@@ -70,11 +70,11 @@ check_installed() {
7070 fi
7171}
7272
73- # Remove config symlinks and files
73+ # Remove config symlinks (ONLY symlinks pointing to draphyOS, not restored files!)
7474remove_configs () {
75- print_step " Removing draphyOS configs ..."
75+ print_step " Removing draphyOS config symlinks ..."
7676
77- # Symlinks created by install.sh
77+ # Symlinks created by install.sh - ONLY remove if they're symlinks to draphyOS
7878 SYMLINKS=(
7979 " $HOME /.config/i3/config"
8080 " $HOME /.config/i3/lock.sh"
@@ -94,36 +94,42 @@ remove_configs() {
9494 )
9595
9696 for link in " ${SYMLINKS[@]} " ; do
97+ # ONLY remove symlinks - regular files might be restored backups!
9798 if [ -L " $link " ]; then
98- rm -f " $link "
99- elif [ -f " $link " ]; then
100- # If it's a regular file (not symlink), might be from failed install
101- rm -f " $link "
99+ # Verify it points to draphyOS before removing
100+ local target
101+ target=$( readlink -f " $link " 2> /dev/null)
102+ if [[ " $target " == * " draphyOS" * ]] || [[ " $target " == * " .draphyOS" * ]]; then
103+ rm -f " $link "
104+ fi
102105 fi
103106 done
104107
105- # Remove cheatsheets directory (copied, not symlinked )
108+ # Remove cheatsheets directory (copied by draphyOS, safe to remove )
106109 rm -rf " $HOME /.config/i3/scripts/cheatsheets" 2> /dev/null || true
107110
108- # Remove wallpaper (copied, not symlinked)
109- rm -f " $HOME /.config/wallpaper.png" 2> /dev/null || true
111+ # Remove draphyOS wallpaper only (not user's wallpaper)
112+ # Check if it's the draphyOS wallpaper before removing
113+ if [ -f " $HOME /.config/wallpaper.png" ]; then
114+ # Only remove if no backup exists (meaning it's draphyOS wallpaper)
115+ local has_backup=false
116+ for backup_wp in " $HOME " /.config-backup-* /wallpaper.png; do
117+ if [ -f " $backup_wp " ]; then
118+ has_backup=true
119+ break
120+ fi
121+ done
122+ if [ " $has_backup " = false ]; then
123+ rm -f " $HOME /.config/wallpaper.png" 2> /dev/null || true
124+ fi
125+ fi
110126
111- # Remove empty directories created by install (only if empty)
127+ # Remove empty directories ONLY if they're truly empty
112128 rmdir " $HOME /.config/i3/scripts" 2> /dev/null || true
113- rmdir " $HOME /.config/i3" 2> /dev/null || true
114129 rmdir " $HOME /.config/polybar/scripts" 2> /dev/null || true
115- rmdir " $HOME /.config/polybar" 2> /dev/null || true
116- rmdir " $HOME /.config/rofi" 2> /dev/null || true
117- rmdir " $HOME /.config/dunst" 2> /dev/null || true
118- rmdir " $HOME /.config/picom" 2> /dev/null || true
119- rmdir " $HOME /.config/fish" 2> /dev/null || true
120- rmdir " $HOME /.config/gtk-3.0" 2> /dev/null || true
121- rmdir " $HOME /.config/redshift" 2> /dev/null || true
122- rmdir " $HOME /.config/xfce4/xfconf/xfce-perchannel-xml" 2> /dev/null || true
123- rmdir " $HOME /.config/xfce4/xfconf" 2> /dev/null || true
124- rmdir " $HOME /.config/xfce4" 2> /dev/null || true
125-
126- print_success " Configs removed"
130+ # Don't remove main config dirs - they might have restored configs!
131+
132+ print_success " draphyOS symlinks removed"
127133}
128134
129135# Revert fish shell to bash (optional)
@@ -273,22 +279,32 @@ remove_battery_limit() {
273279 fi
274280}
275281
276- # Remove LightDM customization
282+ # Remove LightDM customization (careful not to break graphical login)
277283remove_lightdm () {
284+ # Detect base system
285+ local base_system=" "
286+ if [ -f " $MARKER_FILE " ]; then
287+ base_system=$( grep " ^BASE_SYSTEM=" " $MARKER_FILE " 2> /dev/null | cut -d= -f2)
288+ fi
289+
290+ # Only touch LightDM if we have a backup to restore
278291 if [ -f /etc/lightdm/lightdm-gtk-greeter.conf.backup ]; then
279292 print_step " Restoring original LightDM config..."
280293 sudo mv /etc/lightdm/lightdm-gtk-greeter.conf.backup /etc/lightdm/lightdm-gtk-greeter.conf 2> /dev/null || true
281294 print_success " LightDM restored from backup"
282- elif [ -f /etc/lightdm/lightdm-gtk-greeter.conf ]; then
283- print_step " Resetting LightDM to defaults..."
284- sudo tee /etc/lightdm/lightdm-gtk-greeter.conf > /dev/null << 'EOF '
285- [greeter]
286- #background=
287- #theme-name=
288- #icon-theme-name=
289- #font-name=
290- EOF
291- print_success " LightDM reset"
295+ else
296+ # For Fedora i3 Spin, DON'T reset LightDM - it needs to work!
297+ if [ " $base_system " = " fedora-i3" ]; then
298+ print_step " Keeping current LightDM config (required for i3 Spin)"
299+ else
300+ # For other systems, only remove draphyOS customization if it exists
301+ if grep -q " draphyOS" /etc/lightdm/lightdm-gtk-greeter.conf 2> /dev/null; then
302+ print_step " Removing draphyOS LightDM customization..."
303+ # Keep a working config, just remove draphyOS-specific parts
304+ sudo sed -i ' /draphyOS/d' /etc/lightdm/lightdm-gtk-greeter.conf 2> /dev/null || true
305+ print_success " LightDM customization removed"
306+ fi
307+ fi
292308 fi
293309
294310 # Remove draphyOS wallpaper from system
@@ -533,13 +549,16 @@ main() {
533549
534550 check_installed
535551
536- # Removal steps (reverse order of install)
552+ # IMPORTANT: Restore backup FIRST so user has working configs
553+ # before we remove draphyOS configs
554+ restore_backup
555+
556+ # Now safe to remove draphyOS configs (backup already restored)
537557 remove_configs
538558 remove_battery_limit
539559 remove_lightdm
540560 revert_shell
541561 remove_packages
542- restore_backup
543562 remove_install_dir
544563
545564 echo " "
0 commit comments