#!/bin/sh # Start the desktop session once per boot: the GNOME session or the Wayland # compositor, the X session when it is chosen or when the compositor does not # come up. When the GNOME session does not come up, the compositor starts # instead. 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 (gnome, wayland, x11 or # none), overridden by brintos.session= on the kernel command line. SESSION=wayland GNOME_START=/usr/sbin/brintos-gnome-session 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 CMDLINE=/proc/cmdline 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 "$CMDLINE" 2>/dev/null); 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" ;; gnome) if [ ! -x "$GNOME_START" ]; then say "the GNOME session did not start: $GNOME_START is not installed; starting the Wayland session" elif out=$("$GNOME_START" 2>&1); then say "started the GNOME session ($(printf '%s' "$out" | tail -n 1)): $why" exit 0 else say "the GNOME session did not start: $(printf '%s' "$out" | tail -n 1); starting the Wayland session" fi why="the GNOME session did not start" ;; 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)"