Files
starburst/fedora/fedora-niri.sh
T
2026-07-07 12:30:00 +02:00

109 lines
3.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:-none}"
TWM="${SELECTED_TWM:-none}"
INSTALL_LEVEL="${INSTALL_LEVEL:-full}"
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
echo
color_cyan "Starting Fedora Full setup..."
echo
#------------------------------------------
# Helper functions
#------------------------------------------
install_packages() { sudo dnf install -y "$@"; }
is_package_installed() { rpm -q "$@" &>/dev/null; }
detect_de() {
# Check if a desktop session is currently running or XFCE is available
if [ "${XDG_CURRENT_DESKTOP:-}" ]; then
echo "${XDG_CURRENT_DESKTOP,,}" # lowercase the output
elif command -v xfce4-session >/dev/null 2>&1; then
echo "xfce"
else
echo ""
fi
}
detect_display_manager() {
# Fedora/Systemd way to check the active DM symlink
if [ -L /etc/systemd/system/display-manager.service ]; then
basename "$(readlink /etc/systemd/system/display-manager.service)" | sed 's/\.service//'
else
echo ""
fi
}
switch_display_manager() {
local target_dm="$1"
local current_dm
current_dm=$(detect_display_manager)
if [[ "$current_dm" != "$target_dm" ]]; then
if [[ -n "$current_dm" ]]; then
color_yellow "Disabling existing display manager: $current_dm"
sudo systemctl disable "$current_dm"
fi
color_yellow "Enabling $target_dm..."
sudo systemctl enable "$target_dm"
fi
sudo systemctl set-default graphical.target
}
#------------------------------------------
# Start installation
#------------------------------------------
color_yellow "Starting Niri setup..."
CURRENT_DE="$(detect_de)"
CURRENT_DM="$(detect_display_manager)"
# Add Terra repo
sudo dnf install -y --nogpgcheck --repofrompath 'terra,https://repos.fyralabs.com/terra$releasever' terra-release
pause_if_debug
# Core components for Niri & Noctalia setup
NIRI_PACKAGES=(niri fuzzel swaybg swaylock noctalia-shell)
if [[ -z "$CURRENT_DE" || "$CURRENT_DE" == "none" || "$CURRENT_DE" == "sway" ]]; then
color_cyan "No Desktop Environment detected. Installing Niri + Noctalia Shell..."
# 1. Add the repo first
add_terra_repo
# 2. Install everything
install_packages sddm "${NIRI_PACKAGES[@]}"
switch_display_manager "sddm"
color_green "Niri, Noctalia, and SDDM installed successfully."
else
color_cyan "Detected existing Desktop Environment: $CURRENT_DE"
# Always install the window manager packages
install_packages "${NIRI_PACKAGES[@]}"
if [[ "$CURRENT_DM" == "lightdm" ]]; then
color_yellow "LightDM is currently active. Replacing with SDDM..."
# Fedora equivalent to purge lightdm safely
sudo dnf remove -y lightdm lightdm-gtk
install_packages sddm
switch_display_manager "sddm"
color_green "LightDM removed and replaced with SDDM."
else
color_cyan "Current display manager: ${CURRENT_DM:-none}. Leaving it to handle Niri login sessions."
fi
fi
pause_if_debug
# End of script
color_green "Niri / SDDM setup completed."