diff --git a/setup.sh b/setup.sh index 3f48b95..6372db7 100755 --- a/setup.sh +++ b/setup.sh @@ -640,29 +640,41 @@ rule # environments, GTK3 for the rest) --- info "Tailoring toolkits for DE=$DE / TWM=$TWM..." -# First: is ANY PeaZip flavor already installed? The UI flavors all ship -# /usr/bin/peazip and file-conflict with each other — installing gtk3 over -# an existing qt5 dies mid-transaction (laptop-proven). Any present flavor -# wins; skipping is correct. +# The UI flavors all ship /usr/bin/peazip and file-conflict with each +# other — installing gtk3 over an existing qt5 dies mid-transaction +# (laptop-proven). Behaviors: +# no flavor -> install the environment-appropriate one +# right flavor -> nothing to do +# OTHER flavor -> dnf SWAP to the wanted one (atomic: on failure the +# existing flavor stays, which is the safe outcome) +if [[ "$DE" == "plasma" || "$TWM" == "hyprland" ]]; then + peazip_wanted="peazip-qt6" +else + # XFCE, GNOME, Niri, MangoWC, chadwm: lightweight/generic toolkits + peazip_wanted="peazip-gtk3" +fi peazip_existing="" local_v="" for local_v in peazip-qt5 peazip-qt6 peazip-gtk3 peazip-gtk2; do pkg_installed "$local_v" && peazip_existing="$local_v" done -if [[ -n "$peazip_existing" ]]; then - ok "PeaZip already present ($peazip_existing) - skipping." -else - if [[ "$DE" == "plasma" || "$TWM" == "hyprland" ]]; then - peazip_pkgs="peazip-common peazip-qt6" - else - # XFCE, GNOME, Niri, MangoWC, chadwm: lightweight/generic toolkits - peazip_pkgs="peazip-common peazip-gtk3" - fi + +if [[ -z "$peazip_existing" ]]; then # shellcheck disable=SC2086 - if ! install_packages $peazip_pkgs; then - color_red " Failed: $peazip_pkgs" + if ! install_packages peazip-common "$peazip_wanted"; then + color_red " Failed: peazip-common $peazip_wanted" color_red " (continuing — PeaZip is a convenience, not a dependency)" fi +elif [[ "$peazip_existing" == "$peazip_wanted" ]]; then + ok "PeaZip already present ($peazip_existing)." +else + info "PeaZip $peazip_existing does not match this environment — swapping to $peazip_wanted..." + if ui_quiet_run "Swapping PeaZip: $peazip_existing -> $peazip_wanted" \ + sudo dnf swap -y "$peazip_existing" "$peazip_wanted"; then + ok "PeaZip swapped to $peazip_wanted." + else + warn "Swap failed — keeping the existing $peazip_existing (fully functional)." + fi fi pause_if_debug