![在睡眠模式下运行脚本](https://linux22.com/image/948734/%E5%9C%A8%E7%9D%A1%E7%9C%A0%E6%A8%A1%E5%BC%8F%E4%B8%8B%E8%BF%90%E8%A1%8C%E8%84%9A%E6%9C%AC.png)
我认为 /lib/systemd/system-sleep/ 中的脚本是在计算机从睡眠状态恢复时运行的。(按下计算机上的睡眠按钮。)
除 cvlc 线外,一切正常。
#!/bin/sh
if [ "${1}" == "pre" ]; then
# Do the thing you want before suspend here, e.g.:
echo "we are suspending at $(date)..." > /tmp/systemd_suspend_test
cvlc --play-and-exit /usr/share/sounds/My_Sounds/Short_doorbell.wav
elif [ "${1}" == "post" ]; then
# Do the thing you want after resume here, e.g.:
echo "...and we are back from $(date)" >> /tmp/systemd_suspend_test
cvlc --play-and-exit /usr/share/sounds/My_Sounds/Short_doorbell.wav
fi
我想我在日记里找到了线索。
Sep 10 06:36:12 7 systemd-sleep[8316]: VLC is not supposed to be run as root. Sorry.
Sep 10 06:36:12 7 systemd-sleep[8316]: If you need to use real-time priorities and/or privileged TCP ports
Sep 10 06:36:12 7 systemd-sleep[8316]: you can use /usr/bin/vlc-wrapper (make sure it is Set-UID root and