164 lines
5.1 KiB
Bash
Executable File
164 lines
5.1 KiB
Bash
Executable File
#!/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 (Configured unconditionally)
|
|
color_cyan "Pre-configuring XFCE default terminal settings for Alacritty..."
|
|
|
|
# 1. Force initialize the base XDG/XFCE config hierarchy
|
|
mkdir -p "$HOME/.config/xfce4"
|
|
mkdir -p "$HOME/.config/menus"
|
|
|
|
# 2. Configure XFCE's preferred application files
|
|
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
|
|
|
|
# 3. Create the standard XDG MIME association files manually
|
|
mkdir -p "$HOME/.config"
|
|
MIME_FILE="$HOME/.config/mimeapps.list"
|
|
touch "$MIME_FILE"
|
|
|
|
# Rewrite/initialize the file cleanly with explicit defaults
|
|
cat <<EOF > "$MIME_FILE"
|
|
[Default Applications]
|
|
x-scheme-handler/terminal=alacritty.desktop
|
|
user-extension/x-terminal-emulator=alacritty.desktop
|
|
EOF
|
|
|
|
# 4. Pre-seed Xfconf properties directly into the XML tree file structure
|
|
# This bypasses xfconf-query entirely and drops settings directly into storage
|
|
XFCONF_DIR="$HOME/.config/xfce4/xfconf/xfce-perchannel-xml"
|
|
mkdir -p "$XFCONF_DIR"
|
|
|
|
cat <<EOF > "$XFCONF_DIR/xfce4-session.xml"
|
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
<channel name="xfce4-session" version="1.0">
|
|
<property name="general" type="empty">
|
|
<property name="TerminalEmulator" type="string" value="alacritty"/>
|
|
</property>
|
|
</channel>
|
|
EOF
|
|
|
|
color_green "XFCE terminal presets dropped into user skeleton profiles successfully."
|
|
|
|
fi
|
|
pause_if_debug
|
|
|
|
# End of script
|
|
color_green "XFCE / SDDM setup completed." |