How should I determine if a user is logged in graphically while lightdm is running?
Posted
by
Jack
on Ask Ubuntu
See other posts from Ask Ubuntu
or by Jack
Published on 2012-10-23T14:25:11Z
Indexed on
2014/05/26
22:03 UTC
Read the original article
Hit count: 252
lightdm
|console-kit
I want to know if someone is logged into a local X-session. In the past I looked at the output of ck-list-sessions. The output looked something like this:
Session12:
unix-user = '[redacted]'
realname = '[redacted]'
seat = 'Seat1'
session-type = ''
active = TRUE
x11-display = ':0'
x11-display-device = '/dev/tty8'
display-device = ''
remote-host-name = ''
is-local = TRUE
on-since = '2012-10-22T18:17:55.553236Z'
login-session-id = '4294967295'
If no one was logged in, there was no output. I checked if someone was logged in with
ck_result" string => execresult("/usr/bin/ck-list-sessions | /bin/grep x11 | /usr/bin/cut --delimiter=\\' -f 2 | /usr/bin/wc -w
This no longer works, because lightdm greeter looks like a logged in user
Session12:
unix-user = '[redacted]'
realname = 'Light Display Manager'
seat = 'Seat1'
session-type = 'LoginWindow'
active = TRUE
x11-display = ':0'
x11-display-device = '/dev/tty8'
display-device = ''
remote-host-name = ''
is-local = TRUE
on-since = '2012-10-22T22:17:55.553236Z'
login-session-id = '4294967295'
I guess I could check session-type, but I don't know how to do that and check x11-display in one-liner. I then need to write my own script, but at that point I thought I would check if anyone else has already done the work or if there is a way to get ConsoleKit to tell me what I want (or if I should be using a different tool)?
© Ask Ubuntu or respective owner