buc*_*000 7 xfce arch-linux lock-screen xfce4
我在笔记本电脑上使用 lightdm 和 xfce。这是一个新安装。每次屏幕因不活动而关闭(或合上盖子)时,我都会看到 lightdm 登录屏幕。然而,在我登录后,几秒钟后,会弹出一个标题为“错误”的窗口。
如果我合上盖子,解锁,然后在几秒钟内再次合上盖子,我也会看到该错误。我什至不知道错误是从哪里来的。
我没有专门使用 ArchLinux,但由于可能不同的原因(目前我还不清楚),该问题不断出现在运行 XFCE DE 的不同发行版上。最近,当我安装Clight时,它出现在 Ubuntu 中。禁用 Clight 后,锁定工作正常。
默认情况下xfce4-power-manager,不会将任何有用的输出记录到syslog或.xsession-errors。为了解决该问题,请终止自动启动的守护进程并在调试模式下在前台启动:
~$ xfce4-power-manager --quit
~$ xfce4-power-manager --no-daemon --debug
Run Code Online (Sandbox Code Playgroud)
当从orxfce_screensaver_lock调用并返回失败时,会出现以下消息:xfpm_power_sleepxfpm_manager_lid_changed_cb
所有屏幕锁定工具均未成功运行,屏幕不会被锁定。是否仍要继续暂停系统?
因此,请检查您的屏幕保护程序、xfconf-query -c xfce4-session -p /general/LockCommand设置和命令:xflock4、xdg-screensaver等xscreensaver-command。
Lock screen when system is going to sleep然而,一个简单的解决方案是根本不使用 XFCE Power Manager 的设置。定义一个systemd服务以在进入睡眠和/或休眠之前运行锁定命令。另一个好处是,即使您从命令行暂停系统,这也会锁定屏幕。
# /etc/systemd/system/screen_lock@.service
[Unit]
Description=Autolock screen before sleep, hibernate and hybrid-sleep
Before=sleep.target hibernate.target hybrid-sleep.target
[Service]
User=%i # may also hardcode username here
Type=forking
Environment=DISPLAY=:0 # replace this with your $DISPLAY value
ExecStart=/usr/bin/xtrlock # use whatever lock command
ExecStartPost=/bin/sleep 1
[Install]
WantedBy=sleep.target hibernate.target hybrid-sleep.target
Run Code Online (Sandbox Code Playgroud)
启用该服务:
~$ sudo systemctl enable screen_lock@<username>.service
Run Code Online (Sandbox Code Playgroud)