#!/bin/bash set -euo pipefail # Map the exported variables to your local names with fallbacks to satisfy set -u OS="${DETECTED_OS:-fedora}" DE="${SELECTED_DE:-xfce}" TWM="${SELECTED_TWM:-none}" INSTALL_LEVEL="${INSTALL_LEVEL:-minimal}" SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" echo color_cyan "Starting Fedora XFCE setup..." echo #------------------------------------------ # Helper functions #------------------------------------------ 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" || "$CURRENT_DE" == "none" ]]; then color_cyan "No Desktop Environment detected. Installing XFCE (light setup with SDDM)..." # 1. Install core XFCE desktop components + SDDM install_packages sddm xfce4-session xfce4-settings xfwm4 xfce4-panel xfdesktop Thunar xorg-x11-xinit xorg-x11-server-Xorg xhost # 2. Install the XFCE core plugins safely via DNF group/virtual syntax install_packages @xfce-extra-plugins enable_graphical_target sudo systemctl enable sddm color_green "XFCE with SDDM installed successfully. You can reboot now to start XFCE." else color_cyan "Detected existing Desktop Environment: $CURRENT_DE" if [[ "$CURRENT_DM" == "lightdm" ]]; then color_yellow "LightDM is currently active. Replacing with SDDM..." sudo systemctl disable lightdm sudo dnf remove -y lightdm lightdm-gtk-greeter install_packages sddm sudo systemctl enable sddm enable_graphical_target color_green "LightDM removed and replaced with SDDM." else color_cyan "Current display manager: ${CURRENT_DM}. Leaving unchanged." fi fi pause_if_debug #------------------------------------------ # XFCE-specific configuration #------------------------------------------ if [[ "${DE}" == "xfce" || "${DDE}" == "xfce" ]]; then echo color_cyan "Applying XFCE defaults: fonts, browser, and terminal..." # Ensure xfconf-query exists (for XFCE settings) if ! command -v xfconf-query >/dev/null 2>&1; then color_yellow "xfconf-query not found — installing xfce4-settings..." install_packages xfce4-settings fi pause_if_debug # 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" || true # Monospace font (terminals, editors) 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 pause_if_debug # Set default terminal to Alacritty if command -v alacritty >/dev/null 2>&1; then # 1. Update the traditional XFCE helpers file mkdir -p "$HOME/.config/xfce4" HELPERS_FILE="$HOME/.config/xfce4/helpers.rc" touch "$HELPERS_FILE" for entry in TerminalEmulator TerminalEmulatorCommand; do if grep -q "^${entry}=" "$HELPERS_FILE"; then sed -i "s|^${entry}=.*|${entry}=alacritty|" "$HELPERS_FILE" else echo "${entry}=alacritty" >> "$HELPERS_FILE" fi done # 2. Update XFCE's internal configuration database (Xfconf) # This tells the panel applets and shortcut keys exactly what engine binary to execute if command -v xfconf-query >/dev/null 2>&1; then # Create the channel property if it doesn't exist, and force set it to alacritty xfconf-query -c xfce4-session -p /general/TerminalEmulator -s "alacritty" --create 2>/dev/null || \ xfconf-query -c xfce4-session -p /general/TerminalEmulator -s "alacritty" fi # 3. Set standard XDG MIME Association for terminal execution # This prevents XFCE's exo-helper from prompting you on first launch mkdir -p "$HOME/.config" MIME_FILE="$HOME/.config/mimeapps.list" touch "$MIME_FILE" # Ensure the [Default Applications] header exists if ! grep -q '\[Default Applications\]' "$MIME_FILE"; then echo "[Default Applications]" >> "$MIME_FILE" fi # Associate terminal/x-terminal-emulator scheme with alacritty if ! grep -q 'x-terminal-emulator=' "$MIME_FILE"; then sed -i '/\[Default Applications\]/a x-scheme-handler/terminal=alacritty.desktop\nuser-extension/x-terminal-emulator=alacritty.desktop' "$MIME_FILE" fi color_green "XFCE default terminal set to alacritty across helpers, xfconf, and XDG handlers!" fi pause_if_debug # End of script color_green "XFCE / SDDM setup completed."