"failed to lock the screen" when suspending

Lock and suspend broke sometime in the last year and I’m getting around to trying to fix it.

I have installed xfce4-screensaver, and since that wasn’t working I also installed xlockmore and light-locker but these made no difference. xflock4 does not work. I can lock the screen on the command line using xfce4-screensaver-command --lock.

I tried several things in the Settings to troubleshoot this. I tried each of them with auto-suspend (after power manager timeout) and manual suspend (using the taskbar button).

There are three settings in the Power Manager:

  • SUSPEND timeout on the System tab
  • DISPLAY sleep timeout on Display tab (display power management must be enabled)
  • LOCK checkbox on the System tab

SUSPEND no, DISPLAY no, LOCK no

  • manual lock: broken (does nothing)
  • manual suspend: correct (suspends but does not lock the screen)
  • auto lock: disabled
  • auto suspend: disabled
  • makes no difference is “display power management” is toggled

SUSPEND no, DISPLAY no, LOCK yes

  • manual lock: broken (does nothing)
  • manual suspend: broken (displays dialog “failed to suspend session, failed to lock the screen”)
  • auto lock: disabled
  • auto suspend: disabled
  • makes no difference is “display power management” is toggled

SUSPEND no, DISPLAY yes, LOCK no

  • manual lock: broken (does nothing)
  • manual suspend: broken (displays dialog “failed to suspend session, failed to lock the screen”)
  • auto lock: yes (and locks screen)
  • auto suspend: disabled

SUSPEND no, DISPLAY yes, LOCK yes

  • manual lock: broken (does nothing)
  • manual suspend: broken (displays dialog “failed to suspend session, failed to lock the screen”)
  • auto lock: yes (and locks screen)
  • auto suspend: disabled

SUSPEND yes, DISPLAY no, LOCK no

  • manual lock: broken (does nothing)
  • manual suspend: correct (suspends, does not lock screen)
  • auto suspend: correct (suspends, does not lock screen)

SUSPEND yes, DISPLAY no, LOCK yes

  • manual lock: broken
  • manual suspend: broken (does nothing, displays dialog “failed to suspend session, failed to lock the screen”)
  • auto suspend: broken (does not suspend, says “None of the screen tools ran successfully, the screen will not be locked. Do you still want to continue to suspend the system?”)

SUSPEND short, DISPLAY long, LOCK no, suspend kicks in first

  • manual lock: broken
  • manual suspend: correct
  • auto suspend: works (suspends and doesn’t lock)

SUSPEND long, DISPLAY short, LOCK no, display kicks in first

  • manual lock: broken
  • manual suspend: broken (does nothing, displays dialog “failed to suspend session, failed to lock the screen”)
  • auto lock: ok (locks)
  • auto suspend: broken (suspends but also locks even though you said not to)

SUSPEND short, DISPLAY long, LOCK yes, suspend kicks in first

  • manual lock: broken
  • manual suspend: broken (does nothing, displays dialog “failed to suspend session, failed to lock the screen”)
  • auto suspend: broken (locks but does not suspend, says “None of the screen tools ran successfully, the screen will not be locked. Do you still want to continue to suspend the system?”)

SUSPEND long, DISPLAY short, LOCK yes, display kicks in first

  • manual lock: broken
  • manual suspend: broken (does nothing, displays dialog “failed to suspend session, failed to lock the screen”)
  • auto lock: ok (locks)
  • auto suspend: broken (does nothing, says “None of the screen tools ran successfully, the screen will not be locked. Do you still want to continue to suspend the system?”)

Looking over these results:

  • manual lock never works under any circumstances
  • manual suspend works only if display power is disabled AND lock is disabled
  • auto lock works if timeout is set
  • auto suspend works if the “lock on suspend” button is disabled. If the auto lock kicks in first it will lock, otherwise it will not lock.

I am able to use the lock button in the whisker menu by setting the command to “xfce4-screensaver-command --lock”

This all seems horribly broken. Is there any way to get everything to work?

Xfce - Session - Lock the screen - ArchWiki
xflock4 is the reference Shell script which is used to lock an Xfce session.

It tries to lock the screen with these screen lockers in the specified order:

  • xfce4-screensaver

It exits with return code 1 if it fails to find any of these.

To have xflock4 run a custom session locker, set LockCommand in the session’s xfconf channel to the command line to be used:

$ xfconf-query --create -c xfce4-session -p /general/LockCommand -t string -s "*session-locker-command*"

The panel lock button in the Action Buttons panel simply executes /usr/bin/xflock4. It should work as expected as long as xflock4 is functioning i.e. one of the native lockers is installed or a custom locker is configured to integrate with it as proposed above.

To check xflock4 Lock Command:

xfconf-query -c xfce4-session -p /general/LockCommand

To set working lock command for xflock4:

xfconf-query -c xfce4-session -p /general/LockCommand -t string -s "xfce4-screensaver-command --lock"
2 Likes

Thank you so much.

I removed light-locker, and ran the last command you indicated:

xfconf-query -c xfce4-session -p /general/LockCommand -t string -s "xfce4-screensaver-command --lock"

Everything is working now.

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.