我编写了一个简单的 init.d 脚本来启动硬件监控脚本。它工作正常,只是无法访问 alsa 音频服务:
#! /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
say
我从命令和 python 脚本中得到的错误是:
audio_open_alsa: failed to open audio device default. Operation not permitted
编辑:如果 python 脚本由 root 用户通过交互式 shell 正常启动,则它可以访问 alsa,只有在启动过程中作为服务启动或通过service hwleds start
.
我的实际情况/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;
}
答案1
在volumio上也有同样的问题。通过删除.alsaequal.bin
来解决/var/lib/mpd/