Why doesn't my screen lock in XFCE?
Solution 1
Do I need to install a screensaver package or something?
Yes, according to the wiki, you need to choose and install a locker. xflock4
will then activate it.
Solution 2
First install light-locker
.
$ xfconf-query -c xfce4-session -p /general/LockCommand -s "light-locker-command -l"
or if you don't have the variable yet:
$ xfconf-query -c xfce4-session -p /general/LockCommand -s "light-locker-command -l" --create -t string
Old stuff:
Looks like xflock4
does support external config now. What I did is:
$ xfconf-query -c xfce4-session -p /general/LockCommand -s "dm-tool lock"
Now that command is used for locking. I guess gnome-screen-saver broke on upgrade.
This is for XFCE. If you don't have that property already, you add it by:
$ xfconf-query -c xfce4-session -p /general/LockCommand -s "dm-tool lock" --create -t string
VERY IMPORTANT: you need a screensaver running to securely lock your screen. light-locker
is one choice. At the end make sure switching consoles with ctrl+alt+F1 or some other F# does not let you circumvent the lock screen. See:
- https://bugs.launchpad.net/ubuntu/+source/lxsession/+bug/1205384
- https://bugzilla.redhat.com/show_bug.cgi?id=1300178
Solution 3
Edit /usr/bin/xflock4
and append light-locker-command -l
or dm-tool lock
to the list.
for lock_cmd in \
"xscreensaver-command -lock" \
"gnome-screensaver-command --lock" \
"light-locker-command -l"\
"dm-tool lock"
Solution 4
Case_of's answer was close for me, but dm-tool was already listed in my
/usr/local/bin/xflock4
. But it tried xscreensaver-command
and gnome-screensaver-command
first. I moved those to the second for loop, and moved dm-tool up as the only option at first (removing the first for loop):
dm-tool lock >/dev/null 4>&1 && exit
# else run another access locking utility, if installed
for lock_cmd in \
"xscreensaver-command -lock" \
"gnome-screensaver-command --lock"
"xlock -mode blank" \
"slock"
do
set -- $lock_cmd
if command -v -- $1 >/dev/null 2>&1; then
$lock_cmd >/dev/null 2>&1 &
# turn off display backlight:
xset dpms force off
exit
fi
done
I also mapped it to Win+L, to be like Windows.
Solution 5
/usr/bin/xscreensaver
was not running. Fixed by opening xfce4-settings-manager
, opening screen saver section, it asked to run xscreensaver daemon, clicked yes and the locking works now.
Related videos on Youtube
cjm
Updated on September 18, 2022Comments
-
cjm almost 2 years
I'm trying out XFCE on Arch Linux, and for some reason the Lock Screen option in the session menu doesn't do anything. Neither does running
xflock4
at the command line (it exits 0 with no output).xfce4-session
is running.Do I need to install a screensaver package or something?
-
cjm over 10 yearsActually, gnome-screensaver is installed, and it was working under Gnome. Do I need to activate it somehow?
-
cjm over 10 yearsOk, the problem seems to be that
gnome-screensaver-command
exists, butgnome-screensaver
is not running.xflock4
runsgnome-screensaver-command --lock
, which does nothing but exits 0, soxflock4
thinks it's done. -
cjm over 10 yearsI prefer i3lock as a simple screen locker, which isn't directly supported by
xflock4
, so I wrote a simple wrapper script as/usr/bin/xscreensaver-command
that invokesi3lock
. Sincexflock4
triesxscreensaver-command
beforegnome-screensaver-command
, that fixes the problem. -
jasonwryan over 10 years
slock
is even simpler and now comes with a feature: colour! -
Mark K Cowan about 9 years@jasonwryan: Ugh, just a gimmicky trend. Colour display is no more useful than having over 640k of RAM...
-
Kev almost 6 yearsThis also works for Linux Mint 19, if anyone is looking for that.
-
nachopro about 5 yearsThanks! I'm a migrating from XFCE4 to BSPWM, now i3lock works great!
-
Fred over 4 yearsi was trying to use slock, built from source. slock is used as a fallback locker by default, but if you build from source you need to add
/usr/local/bin
to the path up top. -
simonzack over 4 yearsNeed to run
xfce4-screensaver &
after installing it too. I was wondering why it didn't work after install.