Files
fedora/lib/session.sh
T
Pathfinder eacceee296 polkit agent: polkit-gnome is orphaned/EPEL-only on F44; use polkit-kde
VM run failed: 'No match for argument: polkit-gnome'. polkit-gnome is
orphaned in Fedora (EPEL9 only). polkit-kde 6.6.4 is in F44 and ships its
agent's /etc/xdg/autostart .desktop itself, so the manual symlink wiring
is gone too — installing the package is the whole fix.
2026-10-27 14:07:49 +01:00

96 lines
3.2 KiB
Bash

# 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→sddm).
# * 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() {
# polkit-kde ships the agent AND its /etc/xdg/autostart .desktop itself —
# no manual wiring needed. (polkit-gnome is orphaned, EPEL-only: not on F44,
# which is why the first attempt failed with "No match for argument".)
install_packages \
xdg-desktop-portal \
polkit \
polkit-kde \
pipewire \
pipewire-pulseaudio \
wireplumber
}