#!/bin/sh # Start the desktop session once per boot: the Wayland compositor by default, # the X session when it is chosen or when the compositor does not come up. # Says on the console which session started and why. Run from /etc/inittab # under busybox init, or from /.bashrc when bash is PID 1. # # The choice: SESSION in /etc/default/brintos-session (wayland, x11 or none), # overridden by brintos.session= on the kernel command line. SESSION=wayland WAYLAND_START=/usr/sbin/brintos-wayland-start X11_START=/usr/sbin/brintos-x11-start STAMP=/tmp/.brintos-session-started STATE=/tmp/brintos-session.log CONF=/etc/default/brintos-session why="the built-in default" [ -r "$CONF" ] && . "$CONF" && why="SESSION=$SESSION in $CONF" if [ -n "$BRINTOS_SESSION_CONF" ]; then . "$BRINTOS_SESSION_CONF" && why="SESSION=$SESSION in $BRINTOS_SESSION_CONF" fi for x in $(cat /proc/cmdline); do case $x in brintos.session=*) SESSION=${x#*=} why="brintos.session=$SESSION on the kernel command line" ;; esac done (set -C; : > "$STAMP") 2>/dev/null || exit 0 say() { echo "brintos-session: $*" >&2 echo "brintos-session: $*" >> "$STATE" } x11() { if [ ! -x "$X11_START" ]; then say "no session started: $1, and $X11_START is not installed" exit 1 fi say "starting the X11 session: $1" exec "$X11_START" } case $SESSION in none) say "no session started: $why" exit 0 ;; x11) x11 "$why" ;; wayland) ;; *) x11 "unknown session '$SESSION' ($why)" ;; esac [ -x "$WAYLAND_START" ] || x11 "$WAYLAND_START is not installed" if out=$("$WAYLAND_START" 2>&1); then say "started the Wayland session (weston; X11 clients through Xwayland): $why" exit 0 fi x11 "the Wayland compositor did not start: $(printf '%s' "$out" | tail -n 1)"