One of the most basic security features of any laptop or workstation is the ability to lock the sscreen. It might be convenient in many other, non-security related, scenarios as well. In most cases, this feature works without user's intervention on most of the Linux distributions, yet it did not work for me in Xfce4 with LightDM on Arch Linux. As I understand, Xfce does not have its display manager, so it relies on third-party solutions, mostly Gnome Display Manager (GDM). As I prefer Xfce as my desktop environment, I did not want to install GDM as it needs many Gnome libraries to work. Because of this, I decided to use LighDM as my display manager, which is more desktop environment agnostic and lightweight. Unfortunately, Xfce lacks proper integration with it (at least in Arch Linux). In this post, I want to provide a solution to this problem. Moreover, I believe that information in this post might give some ideas to the users of the other desktop environments and window managers on how to integrate them with LightDM.
To some extent, this post is a continuation of the other LightDM related post which I have posted earlier.
If the first two buttons from the image below do not work on your system, you might want to continue reading this post.
How Xfce Initiates Screen Locking and User Switching
Xfce does not do screen locking or user switching itself, it delegates this functionality to the other programs.
For screen locking Xfce executes
xflock4 program which is a shell script. The script locks the session by calling the following programs if they are present on the system (in the following order):
Similarly, Xfce delegates user switching to the gdmplexiserver which is (or was) a part of the Gnome Display Manager package. As you can see, Xfce is attuned to reuse some of the parts of the GNOME desktop environment.
Considering that LightDM has its utility to control itself, the
dm-tool, we might try to "deceive" Xfce to invoke the
dm-tool instead. We could accomplish that by placing the scripts which call the
dm-tool with a required parameter (
switch-to-greeter) and are named as above mentioned programs into a directory from the
$PATH environmental variable (
/usr/local/bin seems like the right choice).
The Scripts to Perform Screen Locking and User Switching
At this point, it is obvious that we need two executable shell scripts, one for session locking and one for user switching, which we should place into
/usr/local/bin folder. For the first one, I propose to use the name
xlock (I used to recommend
xscreensaver-command, but I had some problems in SMPlayer in this case). Here is the code:
#!/bin/sh # fake slock to make xflock to use lightdm locker DMTOOL_AVAILABLE="$(which dm-tool)" if [ -n $DMTOOL_AVAILABLE ] ; then dm-tool lock fi
For the second case, user switching, we might use a very similar script, named as
gdmplexiserver (the only difference is a parameter to the
#!/bin/sh # fake gdmplexiserver to make xflock to use lightdm locker # for user switching DMTOOL_AVAILABLE="$(which dm-tool)" if [ -n $DMTOOL_AVAILABLE ] ; then dm-tool switch-to-greeter fi
If you are a
systemd user, you might try to use a script which relies on
loginctl for both cases:
#!/bin/sh LOGINCTL_AVAILABLE="$(which loginctl)" if [ -n $LOGINCTL_AVAILABLE ] ; then loginctl lock-session fi
After you have done all the steps mentioned above, screen locking and user switching in Xfce should work as expected.
20.07.19 - Note about problems with