Success!
I've hacked together a solution that relies on the PulseAudio session daemon in that systemd is configured to automatically log in a preconfigured user on tty1, whereupon said user then runs squeezelite (as a daemon) followed by kodi (recompiled with '--enable-pulseaudio') via an appropriate if-statement in the user's .bashrc file.
First, I used
this guide (Automatic_login_to_virtual_console) to set up the automatic logon to tty1.
Then, I set up my user to be a member of the 'power' group and configured the user's .bashrc to look like this:
$this->bbcode_second_pass_code('', '
#
# ~/.bashrc
#
# If not running interactively, don't do anything
[[ $- != *i* ]] && return
# We want the session PulseAudio daemon to start before first squeezelite
# (running daemonized with a pidfile) and then kodi both start up.
# Instead of using service files, we're logging into the local tty1
# automatically on boot and every time we exit the shell we automatically log in again.
# We rely on the fact that $XDG_VTNR is set when we log on to a VT on the RPi2.
if [ -n "$XDG_VTNR" -a "$XDG_VTNR" = "1" ]; then
/usr/bin/squeezelite -m '13:37:de:ad:be:ef' -a 80 -n 'myhostname' -f /tmp/squeezelite.log -P /tmp/squeezelite.pid -z
kodi-standalone
kill $(cat /tmp/squeezelite.pid)
exit
# this will automatically restart squeezelite and kodi on the next (automatic) login
fi
alias ls='ls --color=auto'
PS1='[\u@\h \W]\$ '
export EDITOR=/usr/bin/nano
export VISUAL="$EDITOR"
')
... and now I'm one happy camper.
I installed the
pulseaudio-alsa package and used the 'pacmd' utility (included in the pulseaudio package) to set the default PulseAudio profile to the optical out port on my USB sound card. AFAICT, PA saves this setting across reboots.
I used
ponymix and
pulsemixer-git (AUR) to verify and control the volume settings and configured Kodi to use the default ALSA output (which was now PulseAudio courtesy pulseaudio-alsa). I have yet to ascertain whether all this works with the standard, non-pulseaudio kodi-rbp package.
As an aside, I habitually use the
pacaur AUR helper (which depends on
cower) to painlessly install/build packages. Can't recommend pacaur enough really.
P.S. The distcc cross compile functionality is wicked!