feat: kick-session login wrapper with per-boot logs, shipped by install.sh
This commit is contained in:
parent
a2b7802ec1
commit
d8048fc556
2 changed files with 51 additions and 1 deletions
48
kick-session
Executable file
48
kick-session
Executable file
|
|
@ -0,0 +1,48 @@
|
|||
#!/bin/sh
|
||||
# kick-session -- display-manager session entry for kick.
|
||||
#
|
||||
# A display manager (lightdm/gdm/sddm/greetd) keeps only one generation of
|
||||
# session output (~/.xsession-errors + .old), so crash backtraces and flicker
|
||||
# evidence are lost after two logins. This wrapper persists every boot to
|
||||
# its own timestamped log and then execs kick, passing all arguments
|
||||
# through untouched (screen mode, --panel, tabs, ...). Environment
|
||||
# (KICK_MODE, KICK_LOG, ...) passes through equally untouched.
|
||||
#
|
||||
# Usage (see kick-session.desktop):
|
||||
# env KICK_MODE=standalone kick-session [kick args...]
|
||||
set -u
|
||||
|
||||
USER_NAME=${USER:-unknown}
|
||||
HOME_DIR=${HOME:-/tmp}
|
||||
XDG_HOME=${XDG_DATA_HOME:-$HOME_DIR/.local/share}
|
||||
LOGDIR="$XDG_HOME/kick/logs"
|
||||
if ! mkdir -p "$LOGDIR" 2>/dev/null; then
|
||||
LOGDIR="/tmp/kick-logs-$USER_NAME"
|
||||
mkdir -p "$LOGDIR" 2>/dev/null || LOGDIR="/tmp"
|
||||
fi
|
||||
|
||||
STAMP=$(date +%Y%m%d-%H%M%S 2>/dev/null || echo "nodate")
|
||||
LOG="$LOGDIR/session-$STAMP-$$.log"
|
||||
|
||||
# Retention: keep the newest 10 session logs, prune the rest. Runs before
|
||||
# the current log exists, so the current boot is never a candidate.
|
||||
if [ -d "$LOGDIR" ]; then
|
||||
# shellcheck disable=SC2012
|
||||
ls -t "$LOGDIR"/session-*.log 2>/dev/null | tail -n +11 | xargs -r rm -f --
|
||||
fi
|
||||
|
||||
if command -v kick >/dev/null 2>&1; then
|
||||
KICK_BIN=kick
|
||||
else
|
||||
echo "kick-session: 'kick' not found in PATH=$PATH" >&2
|
||||
exit 127
|
||||
fi
|
||||
|
||||
if exec >"$LOG" 2>&1; then
|
||||
echo "kick-session: logging to $LOG"
|
||||
echo "kick-session: date (utc): $(date -u +%FT%TZ 2>/dev/null || date)"
|
||||
echo "kick-session: args: $*"
|
||||
else
|
||||
echo "kick-session: cannot write $LOG, keeping session fds" >&2
|
||||
fi
|
||||
exec "$KICK_BIN" "$@"
|
||||
Loading…
Add table
Add a link
Reference in a new issue