diff --git a/fedora/fedora-xfce.sh b/fedora/fedora-xfce.sh index d47bfe0..0958ecb 100755 --- a/fedora/fedora-xfce.sh +++ b/fedora/fedora-xfce.sh @@ -17,21 +17,21 @@ if [ ! -t 1 ]; then RED="" GREEN="" YELLOW="" CYAN="" GRAY="" BOLD="" RESET="" fi -color_yellow() { printf '%b' "$YELLOW"; } -color_cyan() { printf '%b' "$CYAN"; } -color_red() { printf '%b' "$RED"; } -color_green() { printf '%b' "$GREEN"; } -color_gray() { printf '%b' "$GRAY"; } -color_reset() { printf '%b' "$RESET"; } +# Updated functions to cleanly accept and print text strings +color_yellow() { printf "%b%s%b\n" "$YELLOW" "$*" "$RESET"; } +color_cyan() { printf "%b%s%b\n" "$CYAN" "$*" "$RESET"; } +color_red() { printf "%b%s%b\n" "$RED" "$*" "$RESET"; } +color_green() { printf "%b%s%b\n" "$GREEN" "$*" "$RESET"; } +color_gray() { printf "%b%s%b\n" "$GRAY" "$*" "$RESET"; } #------------------------------------------ # Use exported variables from main detection script #------------------------------------------ -OS="${DETECTED_OS}" -DDE="${DETECTED_DE:-}" +OS="${DETECTED_OS:-unknown}" +DDE="${DETECTED_DE:-unknown}" DE="${SELECTED_DE:-none}" TWM="${SELECTED_TWM:-none}" -INSTALL_LEVEL="${INSTALL_LEVEL:-minimal}" +SYS_INSTALL_LEVEL="${INSTALL_LEVEL:-minimal}" SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" #------------------------------------------ @@ -40,33 +40,59 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" install_packages() { sudo dnf install -y "$@"; } is_package_installed() { rpm -q "$@" &>/dev/null; } +detect_de() { + echo "${XDG_CURRENT_DESKTOP:-${DESKTOP_SESSION:-}}" +} + +detect_display_manager() { + if systemctl is-active --quiet sddm; then + echo "sddm" + elif systemctl is-active --quiet lightdm; then + echo "lightdm" + elif systemctl is-active --quiet gdm; then + echo "gdm" + else + echo "none" + fi +} + +enable_graphical_target() { + sudo systemctl set-default graphical.target +} + +#------------------------------------------ +# Main Execution Flow +#------------------------------------------ +echo color_yellow "Starting XFCE installation..." CURRENT_DE="$(detect_de)" CURRENT_DM="$(detect_display_manager)" -if [[ -z "$CURRENT_DE" ]]; then - color_cyan -e "No Desktop Environment detected. Installing XFCE (light setup with SDDM)..." +if [[ -z "$CURRENT_DE" || "$CURRENT_DE" == "none" ]]; then + color_cyan "No Desktop Environment detected. Installing XFCE (light setup with SDDM)..." - install_packages sddm xfce4 xfce4-goodies + install_packages sddm xfce4-session xfce4-settings xfwm4 xfce4-panel xfdesktop Thunar xfce4-goodies enable_graphical_target + sudo systemctl enable sddm - color_green -e "XFCE with SDDM installed successfully. You can reboot now to start XFCE." + color_green "XFCE with SDDM installed successfully. You can reboot now to start XFCE." else - color_cyan -e "Detected existing Desktop Environment: $CURRENT_DE" + color_cyan "Detected existing Desktop Environment: $CURRENT_DE" if [[ "$CURRENT_DM" == "lightdm" ]]; then - color_yellow -e "LightDM is currently active. Replacing with SDDM..." + color_yellow "LightDM is currently active. Replacing with SDDM..." sudo systemctl disable lightdm - sudo pacman -Rns lightdm lightdm-gtk-greeter + sudo dnf remove -y lightdm lightdm-gtk-greeter install_packages sddm + sudo systemctl enable sddm enable_graphical_target - color_green -e "LightDM removed and replaced with SDDM." + color_green "LightDM removed and replaced with SDDM." else - color_cyan -e "Current display manager: ${CURRENT_DM:-none}. Leaving unchanged." + color_cyan "Current display manager: ${CURRENT_DM}. Leaving unchanged." fi fi @@ -83,22 +109,21 @@ if [[ "${DE}" == "xfce" || "${DDE}" == "xfce" ]]; then install_packages xfce4-settings fi - # set fonts - # Wait for xfconf to be available (only needed if running inside the same session) + # Set fonts via xfconf-query if command -v xfconf-query >/dev/null 2>&1; then # Interface font (UI) - xfconf-query -c xsettings -p /Gtk/FontName -s "RobotoMono Nerd Font Regular 10" + xfconf-query -c xsettings -p /Gtk/FontName -s "RobotoMono Nerd Font Regular 10" || true # Monospace font (terminals, editors) - xfconf-query -c xsettings -p /Gtk/MonospaceFontName -s "RobotoMono Nerd Font Mono Regular 10" + xfconf-query -c xsettings -p /Gtk/MonospaceFontName -s "RobotoMono Nerd Font Mono Regular 10" || true color_green "XFCE fonts updated successfully!" else color_yellow "xfconf-query not found — skipping XFCE font config (will apply at first login)." fi - # Set default terminal + # Set default terminal to Alacritty if command -v alacritty >/dev/null 2>&1; then - mkdir -p "$HOME/.config/xfce4/" + mkdir -p "$HOME/.config/xfce4" HELPERS_FILE="$HOME/.config/xfce4/helpers.rc" touch "$HELPERS_FILE" @@ -116,9 +141,9 @@ if [[ "${DE}" == "xfce" || "${DDE}" == "xfce" ]]; then else echo "TerminalEmulatorCommand=alacritty" >> "$HELPERS_FILE" fi - color_green "XFCE defeault terminal set to alacritty!" + color_green "XFCE default terminal set to alacritty!" fi fi # End of script -color_green -e "XFCE / SDDM setup completed." +color_green "XFCE / SDDM setup completed." \ No newline at end of file