X-Git-Url: https://git.distorted.org.uk/~mdw/profile/blobdiff_plain/d83c96c9be81f185db621dca6cbdc014a1d873d4..11faf2c589af5c8c114dc5b1d627927173fb8224:/dot/xinitrc diff --git a/dot/xinitrc b/dot/xinitrc index 210a76d..87e5bbd 100755 --- a/dot/xinitrc +++ b/dot/xinitrc @@ -25,6 +25,33 @@ run () { esac } +manage () { + local when=$(date +%s) now + local fail=0 rc report + + while :; do + "$@"; rc=$? + case $rc in + 0) info "manage $1: successful exit"; break ;; + 143) info "manage $1: terminated"; break ;; + esac + now=$(date +%s) + report="rc = $rc" + if (( $now - $when > 5 )); then + fail=0 + else + report="$report, early failure" + fail=$(( $fail + 1 )) + if (( $fail >= 5 )); then + info "manage $1: exit ($report), giving up after $fail failures" + break + fi + fi + info "manage $1: exit ($report), restarting" + when=$now + done +} + ## Program choice pick_program () { local what=$1; shift @@ -117,7 +144,7 @@ case "$wm,$vnc" in esac start-e16 () { - run bginit $wm $wmopts + run bginit manage $wm $wmopts win=nil for i in $(seq 10); do sleep 1 @@ -143,7 +170,7 @@ start-window-manager () { start-$wm $wmopts ;; *) - run bginit $wm $wmopts + run bginit manage $wm $wmopts ;; esac } @@ -228,7 +255,7 @@ declare -i \ start-emacs () { GDK_NATIVE_WINDOWS=1 run bgclients noip \ - $emacs -geometry ${emacsx}x${emacsy}+0+0 + $emacs -bg black -geometry ${emacsx}x${emacsy}+0+0 } ## Now place some xterms. @@ -324,7 +351,7 @@ EOF exec "$0" wait nostart ;; :ask-run) - req "Shell command" .cmd.hist xcatch -FMiscFixed6x13 -- sh -c& + req "Shell command" .cmd.hist xcatch -F"Fixed 13" -- sh -c& ;; :ask-command) req "xinit command" .xinit.hist xatom set XINIT_COMMAND$atomtag&