154 lines
5.0 KiB
Bash
Executable File
154 lines
5.0 KiB
Bash
Executable File
#!/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
|
|
|
|
# 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:-unknown}"
|
|
DDE="${DETECTED_DE:-unknown}"
|
|
DE="${SELECTED_DE:-none}"
|
|
TWM="${SELECTED_TWM:-none}"
|
|
SYS_INSTALL_LEVEL="${INSTALL_LEVEL:-minimal}"
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
|
|
#------------------------------------------
|
|
# 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
|
|
|
|
#------------------------------------------
|
|
# 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
|
|
|
|
# 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
|
|
|
|
# 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
|
|
|
|
# End of script
|
|
color_green "XFCE / SDDM setup completed." |