Files
starburst/fedora/fedora-xfce.sh
T
2026-07-06 17:22:03 +02:00

143 lines
4.4 KiB
Bash
Executable File

#!/bin/bash
set -euo pipefail
# Source parent definitions (adjust path if needed)
source "$(dirname "$0")/../main_script.sh"
# 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
mkdir -p "$HOME/.config/xfce4"
HELPERS_FILE="$HOME/.config/xfce4/helpers.rc"
touch "$HELPERS_FILE"
# TerminalEmulator entry
if grep -q '^TerminalEmulator=' "$HELPERS_FILE"; then
sed -i 's|^TerminalEmulator=.*|TerminalEmulator=alacritty|' "$HELPERS_FILE"
else
echo "TerminalEmulator=alacritty" >> "$HELPERS_FILE"
fi
# TerminalEmulatorCommand entry
if grep -q '^TerminalEmulatorCommand=' "$HELPERS_FILE"; then
sed -i 's|^TerminalEmulatorCommand=.*|TerminalEmulatorCommand=alacritty|' "$HELPERS_FILE"
else
echo "TerminalEmulatorCommand=alacritty" >> "$HELPERS_FILE"
fi
color_green "XFCE default terminal set to alacritty!"
fi
fi
pause_if_debug
# End of script
color_green "XFCE / SDDM setup completed."