+failed=
+if installed herbstluftwm; then
+ herbstluftwm --locked >~/.config/herbstluftwm/log 2>&1 || failed=1
+elif installed xmonad; then
+ xmonad || failed=1
+elif installed stumpwm; then
+ stumpwm || failed=1
+else
+ failed='no window manager found'
+fi
+# Fallback in case my window manager failed to start. Otherwise X terminates
+# the session immediately (because xinitrc finishes).
+if test -n "$failed"; then
+ if test x"$failed" = x1; then
+ failed='failed to start window manager'
+ fi
+ error "$failed (spawning fallback terminal)"
+ urxvt || rxvt || xterm
+fi
+
+
+# Cleanup.
+#
+# Kill ssh-agent to prevent unused background processes.
+if test -x /usr/bin/ssh-agent; then
+ /usr/bin/ssh-agent -k >/dev/null
+ # No `eval` necessary, we terminate anyway.
+fi
+# Kill remaining background processes.
+kill $background_pids