按照这个帖子,我似乎可以通过运行来解决声音播放问题aplay -f cd /dev/zero
。我已将命令放入脚本中~/Scripts/openAudio
。我希望脚本从登录运行。我已在创建此文件/etc/systemd/system/openAudio.service
:
[Unit]
Description=open the audio
[Service]
Type=simple
ExecStart=/home/gareth/Scripts/openAudio
[Install]
WantedBy=multi-user.target
然后我这样做了:
sudo systemctl daemon-reload
sudo systemctl enable openAudio
sudo service openAudio start
该命令systemctl status openAudio
给出如下结果且无需运行 aplay:
× openAudio.service - open the audio
Loaded: loaded (/etc/systemd/system/openAudio.service; enabled; preset: enabled)
Active: failed (Result: exit-code) since Tue 2024-01-30 13:06:38 GMT; 5s ago
Duration: 18ms
Process: 7951 ExecStart=/home/gareth/Scripts/openAudio (code=exited, status=1/FAILURE)
Main PID: 7951 (code=exited, status=1/FAILURE)
CPU: 17ms
Jan 30 13:06:38 bramall systemd[1]: Started openAudio.service - open the audio.
Jan 30 13:06:38 bramall openAudio[7952]: aplay: main:834: audio open error: Host is down
Jan 30 13:06:38 bramall systemd[1]: openAudio.service: Main process exited, code=exited, status=1/FAILURE
Jan 30 13:06:38 bramall systemd[1]: openAudio.service: Failed with result 'exit-code'.
关于如何让 aplay 命令从登录时自动运行,有什么建议吗?
编辑:我发现了一个类似的问题这里,但遗憾的是没有答案。