Backport the session log block from the installed copy

/usr/bin/start-hyprcosmic gained this during the blank-screen debugging and
the versioned copy never did, so the next install from this repository would
have silently removed it. Found by diffing the two while writing an installer;
the installer's --check exists so that the next one is not found by hunch.

What it does, unchanged from the copy that has been running: redirect the
session's own output to ~/.cache/hyprcosmic/session.log. A session that fails
drops you at the greeter taking its stderr with it, and by then the journal
cannot be read from inside a session that no longer exists.

A plain redirect rather than tee into a process substitution -- tee would be a
child the session writes through, so its death would deliver SIGPIPE, and
nothing about diagnostics should be able to kill the desktop. Every step is
guarded, so a failure here starts the session with no log rather than refusing
to log in. The previous log is kept as .1 so a second attempt does not erase
the evidence from the first.
This commit is contained in:
2026-08-10 11:48:50 +07:00
parent 04b61b49df
commit c67cb01f2d
+30
View File
@@ -26,6 +26,36 @@ if [[ ! -x "$HYPRCOSMIC_SESSION_BIN" ]]; then
exit 1
fi
# Capture this session's output to a file that outlives it.
#
# A session that fails drops you straight back to the greeter, taking its
# stderr with it -- and by then you cannot read the journal from inside a
# session that no longer exists. A plain file in the cache directory is still
# there afterwards, whatever happened.
#
# A plain redirect, not `tee` into a process substitution: tee would be a child
# process the session writes through, so if it ever died the session would take
# a SIGPIPE. Nothing about diagnostics should be able to kill the desktop.
#
# Every step is guarded. If any of it fails the session starts anyway with no
# log -- losing diagnostics is an inconvenience, refusing to log in is not.
#
# The previous log is kept as .1, so a second attempt does not erase the
# evidence from the first.
HYPRCOSMIC_LOG="${XDG_CACHE_HOME:-$HOME/.cache}/hyprcosmic/session.log"
if mkdir -p "$(dirname "$HYPRCOSMIC_LOG")" 2>/dev/null; then
if [[ -f "$HYPRCOSMIC_LOG" ]]; then
mv -f "$HYPRCOSMIC_LOG" "${HYPRCOSMIC_LOG}.1" 2>/dev/null || true
fi
if : >>"$HYPRCOSMIC_LOG" 2>/dev/null; then
exec >>"$HYPRCOSMIC_LOG" 2>&1
echo "=== hyprcosmic session starting $(date -Is) ==="
echo " session bin: $HYPRCOSMIC_SESSION_BIN"
echo " comp bin: $HYPRCOSMIC_COMP_BIN"
echo " autostart: ${XDG_CONFIG_HOME:-$HOME/.config}/hyprcosmic/autostart"
fi
fi
# Selects the component set in cosmic-session's profile module: cosmic-panel,
# cosmic-launcher, cosmic-app-library, cosmic-workspaces, cosmic-bg and
# cosmic-files-applet are skipped; waybar and friends come from