I've written a simple init.d script to start an hardware monitor script. It works fine except it cannot access the alsa audio service:
#! /bin/sh
SCRIPT_PATH="/d/SharedPrograms/hwleds.py"
case $1 in
start)
say "starting service hwleds..."
python $SCRIPT_PATH &
exit $?
;;
stop)
pkill -f "python $SCRIPT_PATH"
exit $?
;;
restart)
$0 stop
sleep 1
$0 start
;;
*)
echo "Usage: $0 {start|stop|restart}"
exit 1
esac
exit 1
The error i get from both the say command and the python script is:
audio_open_alsa: failed to open audio device default. Operation not permitted
edit: The python script can access alsa if it is started normally by the root user via an interactive shell, it only fails if it is started as a service during boot or via service hwleds start.
My actual /root/.asoundrc:
defaults.pcm.card 0
defaults.pcm.device 3
ctl.equal {
type equal;
}
pcm.plugequal {
type equal;
# Modify the line below if you don't
# want to use sound card 0.
slave.pcm "plughw:0,3";
# or if you want to use with multiple applications output to dmix
# slave.pcm "plug:dmix"
}
#pcm.equal {
# Or if you want the equalizer to be your
# default soundcard uncomment the following
# line and comment the above line.
pcm.!default {
type plug;
slave.pcm plugequal;
}
aplay -Land check/etc/asound.confand~/.asoundrcfor this user, e.g. root)? Maybe a default device doesn't exist for root on your system?/dev/snd/.whoami). Also i'm quite sure root can access the default alsa device because this is puppy linux.defaultdevice. ALSA has user-specific sound configuration, so even if normal users do have adefaultdevice defined (which is just an alias for some other device), that doesn't mean root does. So log in as root, and tryaplay -D default some_wav_file. Then doaplay -Letc.