我使用 ALSA。我想防止 PC 在播放声音时挂起。我使用这个 bash 代码来运行屏幕锁和挂起命令:
# Run a screen locker.
#xautolock -time 5 -locker slimlock &
# Run suspend
#xautolock -time 6 -locker 'systemctl suspend' &
我想检测是否播放了声音或视频并阻止 PC 挂起。例如一个伪代码:
if (video is not played)
{
run a screen locker
}
if (sound is not played and video is not played)
{
run suspend command
}
如何使用命令行实用程序检测声音或视频正在播放?