恢复计算机时运行的脚本放在哪里?

dai*_*isy 9 arch-linux suspend pm-utils

当我的计算机从内存暂停中唤醒时,我需要锁定屏幕,

所以我尝试将以下脚本放入/usr/lib/pm-utils/sleep.dand /etc/pm/sleep.d,但它从未执行过,

#!/bin/sh

case "$1" in
    hibernate|suspend)
        ;;
    thaw|resume)
        vlock -ans
        ;;
    *) exit $NA
        ;;
esac
Run Code Online (Sandbox Code Playgroud)

PS它pm-suspend不是pm-hibernate

编辑

也尝试过 systemd 服务,但没有运气:

# /etc/systemd/system/resume@.service
[Unit]
Description=User resume actions
After=suspend.target

[Service]
User=root
Type=simple
ExecStart=vlock -ans

[Install]
WantedBy=suspend.target
Run Code Online (Sandbox Code Playgroud)

systemctl enable resume@.service也打过电话,vlock 仍然没有被调用。

小智 1

您是否按照wiki 中的描述设置了权限和所有者?

确保该脚本可执行(chmod 755)并且由 root:root 所有