diff --git a/bin/z13-recover-desktop b/bin/z13-recover-desktop new file mode 100755 index 0000000..db1ac4a --- /dev/null +++ b/bin/z13-recover-desktop @@ -0,0 +1,54 @@ +#!/usr/bin/env bash +# Emergency recovery when desktop shows wallpaper but no panels/UI after a profile change. +# Run from TTY: Ctrl+Alt+F3, log in, then: +# sudo /path/to/z13Profiler/bin/z13-recover-desktop + +set -euo pipefail + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +INSTALL_ROOT="$(cd "${SCRIPT_DIR}/.." && pwd)" +export INSTALL_ROOT CONFIG_FILE="${INSTALL_ROOT}/config/profiles.conf" + +# shellcheck source=../lib/memory-profiles.sh +source "${INSTALL_ROOT}/lib/memory-profiles.sh" + +if [[ "${EUID}" -ne 0 ]]; then + echo "Run with sudo." >&2 + exit 1 +fi + +echo "=== z13Profiler desktop recovery ===" +echo "" +echo "Memory now:" +free -h | sed 's/^/ /' +echo "" +if uma_base="$(find_uma_base 2>/dev/null)"; then + echo "UMA carveout index: $(cat "${uma_base}/carveout")" + sed 's/^/ /' "${uma_base}/carveout_options" +fi +echo "" + +echo "Step 1: Reset memory profile to safe defaults (4 GB carveout, no custom TTM)..." +apply_profile reset + +echo "" +echo "Step 2: Try restarting Plasma for logged-in user(s)..." +for udir in /run/user/*; do + [[ -d "${udir}" ]] || continue + uid="${udir##*/}" + user="$(id -nu "${uid}" 2>/dev/null)" || continue + [[ "${user}" == "root" ]] && continue + echo " Restarting plasmashell for ${user} (uid ${uid})..." + sudo -u "${user}" DBUS_SESSION_BUS_ADDRESS="unix:path=${udir}/bus" \ + systemctl --user restart plasma-plasmashell 2>/dev/null \ + || sudo -u "${user}" kstart plasmashell 2>/dev/null \ + || true +done + +echo "" +echo "If the panel still missing, reboot once more:" +echo " sudo reboot" +echo "" +echo "After reboot, verify:" +echo " z13-memory-profiles --status" +echo " free -h" diff --git a/install.sh b/install.sh index 9d8aa41..f86d3a8 100755 --- a/install.sh +++ b/install.sh @@ -38,6 +38,7 @@ rsync -a --delete \ "${SRC_DIR}/" "${INSTALL_DIR}/" chmod +x "${INSTALL_DIR}/bin/z13-memory-profiles" +chmod +x "${INSTALL_DIR}/bin/z13-recover-desktop" 2>/dev/null || true chmod +x "${INSTALL_DIR}/install.sh" 2>/dev/null || true ln -sf "${INSTALL_DIR}/bin/z13-memory-profiles" "${BIN_DIR}/z13-memory-profiles" diff --git a/lib/memory-profiles.sh b/lib/memory-profiles.sh index e9d8dbd..1492c87 100644 --- a/lib/memory-profiles.sh +++ b/lib/memory-profiles.sh @@ -191,20 +191,33 @@ clear_ttm_config() { } regenerate_initramfs() { + # Only needed when /etc/modprobe.d/ttm.conf changes. Carveout (UMA) is firmware + # staged via sysfs and must NOT trigger a full initramfs rebuild — that has caused + # broken sessions on Nobara (wallpaper only, no plasmashell). + if [[ "${REGEN_INITRAMFS:-0}" != "1" ]]; then + log "Skipping initramfs regen (not required for this change)." + return + fi + + local running_kernel + running_kernel="$(uname -r)" + if command -v dracut >/dev/null 2>&1; then - log "Regenerating initramfs (dracut)..." - dracut --force --regenerate-all 2>/dev/null || dracut --force + log "Regenerating initramfs for ${running_kernel} only..." + dracut --force -k "${running_kernel}" || { + log "WARN: dracut failed; try: sudo dracut --force -k ${running_kernel}" + } return fi if command -v update-initramfs >/dev/null 2>&1; then - update-initramfs -u -k all + update-initramfs -u -k "${running_kernel}" return fi if command -v mkinitcpio >/dev/null 2>&1; then mkinitcpio -P return fi - log "No initramfs tool found; reboot may still apply modprobe.d on next boot." + log "No initramfs tool found; modprobe.d applies on next boot without regen." } set_carveout_index() { @@ -245,13 +258,17 @@ apply_profile() { fi if [[ "${ttm_action}" == "clear" ]]; then - clear_ttm_config + if [[ -f "${TTM_CONF}" ]]; then + clear_ttm_config + REGEN_INITRAMFS=1 regenerate_initramfs + else + clear_ttm_config + fi elif [[ -n "${ttm_gb}" ]]; then write_ttm_config "${ttm_gb}" + REGEN_INITRAMFS=1 regenerate_initramfs fi - regenerate_initramfs - cat <