xfdesktop error after inactivity "None of the screen lock tools ran successfully, the screen will not be locked"

Solution 1:

I don't use ArchLinux specifically but the problem keeps on appearing on different distros running XFCE DE due to possibly different reasons (not clearly known to me at the moment). Recently it appeared in Ubuntu when I installed Clight. With Clight disabled, locking works fine.

By default xfce4-power-manager does not log any helpful output to syslog or .xsession-errors. In order to troubleshoot the problem, kill the auto-started daemon and start in foreground in debugging mode:

~$ xfce4-power-manager --quit
~$ xfce4-power-manager --no-daemon --debug

The following message appears when xfce_screensaver_lock is called from xfpm_power_sleep or xfpm_manager_lid_changed_cb and returns failure:

None of the screen lock tools ran successfully, the screen will not be locked. Do you still want to continue to suspend the system?

So look into your screensaver, xfconf-query -c xfce4-session -p /general/LockCommand setting, and commands: xflock4, xdg-screensaver, xscreensaver-command etc.

However a simple solution is to not use XFCE Power Manager's Lock screen when system is going to sleep setting at all. Define a systemd service to run lock command before going to sleep and/or hibernate. An additional benefit is that this would lock the screen even if you suspend the system from commandline.

# /etc/systemd/system/[email protected]

[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

Enable the service:

~$ sudo systemctl enable screen_lock@<username>.service