From 4124624deaa03513243c472a8193c2b4a6bf5ad8 Mon Sep 17 00:00:00 2001 From: "[yuri]" <[yuri.kuit@gmail.com]> Date: Wed, 10 Dec 2025 20:05:04 +0100 Subject: [PATCH] fix arch xfce + add arch plasma --- v2/arch-plasma.sh | 114 ++++++++++++++++++++++++++++++++++++++++++++++ v2/arch-xfce.sh | 32 +++++++++---- 2 files changed, 137 insertions(+), 9 deletions(-) create mode 100755 v2/arch-plasma.sh diff --git a/v2/arch-plasma.sh b/v2/arch-plasma.sh new file mode 100755 index 0000000..b12dc64 --- /dev/null +++ b/v2/arch-plasma.sh @@ -0,0 +1,114 @@ +#!/bin/bash +set -euo pipefail + +########################## +# Color helpers (printf-safe, no tput) +########################## +RED="\033[0;31m" +GREEN="\033[0;32m" +YELLOW="\033[0;33m" +CYAN="\033[0;36m" +GRAY="\033[0;37m" +BOLD="\033[1m" +RESET="\033[0m" + +# Disable colors if output is not a terminal +if [ ! -t 1 ]; then + RED="" GREEN="" YELLOW="" CYAN="" GRAY="" BOLD="" RESET="" +fi + +say_red() { printf "\n"; printf "%b%s%b\n" "$RED" "$*" "$RESET"; } +say_green() { printf "\n"; printf "%b%s%b\n" "$GREEN" "$*" "$RESET"; } +say_yellow() { printf "\n"; printf "%b%s%b\n" "$YELLOW" "$*" "$RESET"; } +say_cyan() { printf "\n"; printf "%b%s%b\n" "$CYAN" "$*" "$RESET"; } +say_gray() { printf "\n"; printf "%b%s%b\n" "$GRAY" "$*" "$RESET"; } +say_bold() { printf "\n"; printf "%b%s%b\n" "$BOLD" "$*" "$RESET"; } + +########################## +# Use exported variables from main detection script +########################## +OS="${DETECTED_OS}" +DDE="${DETECTED_DE}" +DE="${SELECTED_DE:-none}" +TWM="${SELECTED_TWM:-none}" +INSTALL_LEVEL="${INSTALL_LEVEL:-minimal}" +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" + +########################## +# Helper functions +########################## +install_packages() { sudo pacman -S --noconfirm --needed "$@"; } +remove_packages() { sudo pacman -Rs --noconfirm "$@"; } +is_package_installed() { pacman -Qi "$@" &>/dev/null; } + +detect_de() { + if command -v plasmashell >/dev/null 2>&1; then + echo "kde" + else + echo "" + fi +} + +detect_display_manager() { + if [ -f /etc/X11/default-display-manager ]; then + basename "$(cat /etc/X11/default-display-manager)" + else + echo "" + fi +} + +enable_graphical_target() { + sudo systemctl enable sddm + sudo systemctl set-default graphical.target +} + +########################## +# Start installation +########################## +say_yellow -e "Starting KDE Plasma installation..." + +CURRENT_DE="$(detect_de)" +CURRENT_DM="$(detect_display_manager)" + +if [[ -z "$CURRENT_DE" || "$CURRENT_DE" != "kde" ]]; then + say_cyan -e "KDE Plasma not detected. Installing KDE Plasma (light setup with SDDM)..." + + install_packages sddm plasma kde-applications + enable_graphical_target + + say_green -e "KDE Plasma with SDDM installed successfully. You can reboot now to start XFCE." +else + say_cyan -e "Detected existing Desktop Environment: $CURRENT_DE. Checking Display Manager..." + + # Check and replace other Display Managers if they conflict with the preferred SDDM setup + if [[ "$CURRENT_DM" != "sddm" ]]; then + say_yellow -e "Display manager **$CURRENT_DM** is currently active. Replacing with **SDDM**, the default for KDE Plasma..." + + # Attempt to disable the old DM if detected + if [ ! -z "$CURRENT_DM" ]; then + sudo systemctl disable "$CURRENT_DM" || true + fi + + # Remove common alternative DMs if they exist to prevent conflicts + if is_package_installed lightdm; then + say_gray -e "Removing lightdm..." + remove_packages lightdm lightdm-gtk-greeter || true + fi + if is_package_installed gdm; then + say_gray -e "Removing gdm..." + remove_packages gdm || true + fi + + # Ensure SDDM is installed and enabled + install_packages sddm + enable_graphical_target + + say_green -e "Old display manager removed and replaced with SDDM." + else + say_cyan -e "Current display manager is already **SDDM**. Leaving unchanged." + fi +fi + +# End of script +say_green -e "KDE Plasma / SDDM setup completed." + diff --git a/v2/arch-xfce.sh b/v2/arch-xfce.sh index 95cd5ef..353f70a 100755 --- a/v2/arch-xfce.sh +++ b/v2/arch-xfce.sh @@ -70,28 +70,42 @@ say_yellow -e "Starting XFCE installation..." CURRENT_DE="$(detect_de)" CURRENT_DM="$(detect_display_manager)" -if [[ -z "$CURRENT_DE" ]]; then - say_cyan -e "No Desktop Environment detected. Installing XFCE (light setup with SDDM)..." +if [[ -z "$CURRENT_DE" || "$CURRENT_DE" != "xfce" ]]; then + say_cyan -e "XFCE4 not detected. Installing XFCE (light setup with SDDM)..." install_packages sddm xfce4 xfce4-goodies enable_graphical_target say_green -e "XFCE with SDDM installed successfully. You can reboot now to start XFCE." else - say_cyan -e "Detected existing Desktop Environment: $CURRENT_DE" + say_cyan -e "Detected existing Desktop Environment: $CURRENT_DE. Checking Display Manager..." - if [[ "$CURRENT_DM" == "lightdm" ]]; then - say_yellow -e "LightDM is currently active. Replacing with SDDM..." + # Check and replace other Display Managers if they conflict with the preferred SDDM setup + if [[ "$CURRENT_DM" != "sddm" ]]; then + say_yellow -e "Display manager **$CURRENT_DM** is currently active. Replacing with **SDDM**, the default for KDE Plasma..." - sudo systemctl disable lightdm - sudo apt purge -y lightdm lightdm-gtk-greeter + # Attempt to disable the old DM if detected + if [ ! -z "$CURRENT_DM" ]; then + sudo systemctl disable "$CURRENT_DM" || true + fi + + # Remove common alternative DMs if they exist to prevent conflicts + if is_package_installed lightdm; then + say_gray -e "Removing lightdm..." + remove_packages lightdm lightdm-gtk-greeter || true + fi + if is_package_installed gdm; then + say_gray -e "Removing gdm..." + remove_packages gdm || true + fi + # Ensure SDDM is installed and enabled install_packages sddm enable_graphical_target - say_green -e "LightDM removed and replaced with SDDM." + say_green -e "Old display manager removed and replaced with SDDM." else - say_cyan -e "Current display manager: ${CURRENT_DM:-none}. Leaving unchanged." + say_cyan -e "Current display manager is already **SDDM**. Leaving unchanged." fi fi