Restructure for bare Fedora: lib/ + modules/, DE selection restored
Splits setup.sh into lib/common.sh, lib/session.sh and seven modules (3 DE, 4 TWM). Targets a bare Fedora 44+ install. Fixes carried over from the first build: - DEBUG_MODE was unbound under set -u, aborting the script at the version banner - mangled 'echohttps://...' line left over from the starburst split - set -e was missing entirely; --debug flag parsing restored - unguarded 'clear' aborted the run without TERM - $PRETTY_NAME unguarded under set -u - modules were sourced, leaking shell options into the parent - Flathub added twice (system-wide + per-user) - no dnf5-plugins check before using 'dnf config-manager' - no Fedora release gate - /usr/share/xsessions assumed to exist when writing session entries
This commit is contained in:
@@ -0,0 +1,91 @@
|
||||
# shellcheck shell=bash
|
||||
#------------------------------------------
|
||||
# lib/session.sh — display manager and graphical session wiring
|
||||
#
|
||||
# DM policy:
|
||||
# * A DE module leaves its native DM alone (GNOME→gdm, Plasma→sddm, XFCE→lightdm).
|
||||
# * A TWM module enforces SDDM, because SDDM is the only DM that presents both
|
||||
# Wayland compositors and X11 sessions in one menu. One greeter, no surprises.
|
||||
#------------------------------------------
|
||||
|
||||
if [[ -n "${_SB_SESSION_LOADED:-}" ]]; then
|
||||
return 0
|
||||
fi
|
||||
_SB_SESSION_LOADED=1
|
||||
|
||||
# Name of the active display manager ("sddm", "gdm", "lightdm"), or "" if none.
|
||||
detect_display_manager() {
|
||||
local link=/etc/systemd/system/display-manager.service
|
||||
if [[ -L "$link" ]]; then
|
||||
basename "$(readlink "$link")" | sed 's/\.service$//'
|
||||
else
|
||||
echo ""
|
||||
fi
|
||||
}
|
||||
|
||||
enable_graphical_target() {
|
||||
sudo systemctl set-default graphical.target
|
||||
}
|
||||
|
||||
# Make $1 the display manager, disabling whatever is active now.
|
||||
switch_display_manager() {
|
||||
local target="$1"
|
||||
local current
|
||||
current=$(detect_display_manager)
|
||||
|
||||
if [[ "$current" == "$target" ]]; then
|
||||
ok "Display manager already $target."
|
||||
else
|
||||
if [[ -n "$current" ]]; then
|
||||
info "Disabling current display manager: $current"
|
||||
# disable may fail if the unit vanished; that is not fatal
|
||||
sudo systemctl disable "$current" 2>/dev/null || true
|
||||
fi
|
||||
info "Enabling display manager: $target"
|
||||
sudo systemctl enable "$target"
|
||||
fi
|
||||
|
||||
enable_graphical_target
|
||||
}
|
||||
|
||||
# Register a Wayland session so the DM can list it.
|
||||
# $1 = identifier, $2 = display name, $3 = command
|
||||
write_wayland_session() {
|
||||
local id="$1" name="$2" exec_cmd="$3"
|
||||
local file="/usr/share/wayland-sessions/${id}.desktop"
|
||||
if [[ -f "$file" ]]; then
|
||||
ok "Wayland session already registered: $id"
|
||||
return 0
|
||||
fi
|
||||
info "Registering Wayland session: $id"
|
||||
sudo mkdir -p "$(dirname "$file")"
|
||||
printf '[Desktop Entry]\nName=%s\nComment=%s\nExec=%s\nType=Application\nDesktopNames=%s\n' \
|
||||
"$name" "$name session" "$exec_cmd" "$id" | sudo tee "$file" >/dev/null
|
||||
sudo chmod 644 "$file"
|
||||
}
|
||||
|
||||
# Register an X11 session so the DM can list it.
|
||||
write_x11_session() {
|
||||
local id="$1" name="$2" exec_cmd="$3"
|
||||
local file="/usr/share/xsessions/${id}.desktop"
|
||||
if [[ -f "$file" ]]; then
|
||||
ok "X11 session already registered: $id"
|
||||
return 0
|
||||
fi
|
||||
info "Registering X11 session: $id"
|
||||
# A bare Fedora has no X session yet, so the directory may not exist.
|
||||
sudo mkdir -p "$(dirname "$file")"
|
||||
printf '[Desktop Entry]\nName=%s\nComment=%s\nExec=%s\nType=Application\n' \
|
||||
"$name" "$name session" "$exec_cmd" | sudo tee "$file" >/dev/null
|
||||
sudo chmod 644 "$file"
|
||||
}
|
||||
|
||||
# Common login-time plumbing every Wayland compositor wants on a bare install.
|
||||
install_session_prereqs() {
|
||||
install_packages \
|
||||
xdg-desktop-portal \
|
||||
polkit \
|
||||
pipewire \
|
||||
pipewire-pulseaudio \
|
||||
wireplumber
|
||||
}
|
||||
Reference in New Issue
Block a user