4

I found this answer, but that's about Gnome. I couldn't find an answer about Xfce on Super User.

Harm
  • 163
  • 1
  • 6

3 Answers3

5

On my laptop (Arch linux + xfce4) two combinations work

$ xfce4-screensaver-command --lock

and the one mentioned by @Harm

$ xflock4

You can set a keyboard shortcut for locking the screen by going to menu

Applications -> Settings -> Keyboard

Then open tab Application Shortcuts and click on + Add, enter any of the commands mentioned above and click OK (you will be asked to assign a keyboard shortcut to it).

p.s. Note that xflock4 is usually available in keyboard shortcuts under Ctrl-Alt-L.

John Smith
  • 208
  • 2
  • 7
  • I usually _set_ `xflock4` to `Ctrl+Alt+L` but the default I've seen is `Ctrl+Alt+Del`. – That1Guy Oct 07 '22 at 13:06
  • `xfce4-screensaver-command --lock` works for me but not `xflock4`. I may have installed a custom screensaver or uninstalled the default one (can't remember). – pdem Mar 09 '23 at 14:36
2

I found this on ArchWiki. So the canonical way to do this seems to be:

xflock4

This is wrapper (run cat $(which xflock4)) that checks xfconf-query -c xfce4-session -p /general/LockCommand for the configured lock command and tries to run that. It also includes fallbacks to other access locking utilities.

Harm
  • 163
  • 1
  • 6
  • And regarding other access locking utilities, here is [more from the ArchWiki](https://wiki.archlinux.org/title/List_of_applications/Security#Screen_lockers). You can use pretty much anything, but it may be desirable to use something that doesn't have dependencies to a lot of stuff you wouldn't otherwise use. I use LightDM and so uses the accompanying light-locker. – Taqras Jan 19 '22 at 16:55
0

This seemed to work for me:

gsettings set apps.light-locker late-locking false
gsettings set apps.light-locker lock-after-screensaver 0
gsettings set apps.light-locker lock-on-suspend true

The simple way I found that was to enter in a terminal:

dconf watch /

Then make the changes in the GUI like all the tutorials tell you, and keep watch on that terminal.

The output from the terminal is:

/apps/light-locker/late-locking
  false

...which translates into the gsettings command I listed above. FYI value out of unit32 0 means just input 0 for the final value, which is the second line with lock-after-screensaver 0. The unit32 datatype isn't necessary in the command line.

Jesse
  • 123
  • 1
  • 6