How to determine if a session is locked

b3nmore b3nmore at
Mon Oct 13 08:37:52 UTC 2014

Hi all,

I've managed to (hopefully reliably) lock a session when activating a
unlocked session. This means, that we can assume a session locked, if
the user has a running light-locker process.
For those interested I've attached the script to comment #9 of

On 10/10/2014 05:57 PM, b3nmore wrote:
> Hi all,
> I'm using a little python script to implement (fast) user switching,
> which, for my use case (#2 in the list below), works quite well. Now I'm
> trying to generalize it bit, so that others may use it as well. This
> brought up the question, if it is possible to determine if a session is
> locked.
> Here's a (incomplete?) list of use cases I want to cover:
> Switching to a user ...
> 1) not logged in -> equivalent to dm-tool switch-to-user username
> 2) logged in but does not lock its session -> equivalent to loginctl
> activate session_of_username [1]
> 3) logged in and locks screen -> if session is locked: dm-tool
> switch-to-user username else: loginctl activate session_of_username
> For #3 it would be helpful, if one could check if a session is actually
> locked.
> Another issue I haven't solved so far is to lock a current session and
> activate (via logind) another one.
> Any hints you can give me are highly appreciated. Thanks.
> [1] this use case was the reason I wrote the script in the first place:
> I wanted to switch to another session like ctrl+alt+fX just with a mouse
> click.

More information about the xubuntu-devel mailing list