X-Git-Url: https://git.madduck.net/etc/xsession.git/blobdiff_plain/6f1a4b6dbb0f19265df48d27003426309747d31f..refs/heads/master:/.xsession diff --git a/.xsession b/.xsession index f8f3ee8..ea1683e 100755 --- a/.xsession +++ b/.xsession @@ -1,22 +1,36 @@ #!/bin/zsh --login -set -eu - -SHLVL=0 +RUNDIR="/run/user/$(id -u)" +mkdir -m700 -p "$RUNDIR" +NEW_ERRFILE=$RUNDIR/xsession-errors +if [ -f "$ERRFILE" ]; then + mv "$ERRFILE" $NEW_ERRFILE +elif [ -L /tmp/xsession-$LOGNAME ]; then + mv $(readlink -f /tmp/xsession-$LOGNAME) $NEW_ERRFILE + rm /tmp/xsession-$LOGNAME +fi +chmod 600 $NEW_ERRFILE +ln -sf $NEW_ERRFILE $HOME/.xsession-errors + +TRAPS="0 1 2 3 4 5 6 7 8 10 11 12 13 14 15" +cleanup() { + rm -f $HOME/.xsession-errors + mv $NEW_ERRFILE $HOME/.xsession-errors + trap - $TRAPS +} +trap cleanup $TRAPS + +exec >>$NEW_ERRFILE 2>&1 + +set -u while :; do - : >| $HOME/.xsession-errors - for script in $(run-parts --list $HOME/.xsession.d); do echo I: sourcing ${script:t}... >&2 . $script echo I: done sourcing ${script:t}... >&2 done - echo I: waiting for child processes to complete... >&2 - jobs >&2 - wait - [ -e $HOME/.xsession-exit ] && break echo "I: restarting xsession (touch $HOME/.xsession-exit to exit)..." >&2