为什么我的 Before=sleep.target 服务*在恢复后*运行?

为什么我的 Before=sleep.target 服务*在恢复后*运行?

我定义了以下内容服务在挂起之前启动屏幕锁定器:

$ cat /etc/systemd/system/screenlock.service
[Unit]
Description=Lock X session using slock
Before=sleep.target

[Service]
User=my_user
Environment=DISPLAY=:0
ExecStart=/usr/bin/xautolock -locknow

[Install]
WantedBy=sleep.target

启动时加载:

$ systemctl status screenlock.service 
● screenlock.service - Lock X session using slock
   Loaded: loaded (/etc/systemd/system/screenlock.service; enabled)
   Active: inactive (dead)

它在触发 RAM 挂起和恢复工作之间的某个时刻运行:

$ systemctl status screenlock.service 
● screenlock.service - Lock X session using slock
   Loaded: loaded (/etc/systemd/system/screenlock.service; enabled)
   Active: inactive (dead)

Sep 17 08:22:22 machine systemd[1]: Starting Lock X session using slock...
Sep 17 08:22:22 machine systemd[1]: Started Lock X session using slock.

如果它运行了暂停时,为什么恢复时屏幕锁打开之前会看到桌面闪烁?是否Beforesleep.target定义为人们所期望的?是xautolockslock有问题吗?

(我已经通过禁用此服务、暂停、恢复和不获取屏幕锁来验证没有其他服务干扰。)

相关内容