How to determine if a session is locked

b3nmore b3nmore at
Fri Oct 10 15:57:05 UTC 2014

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

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

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

More information about the xubuntu-devel mailing list