how to list active X11 sessions on a local machine?

Thomi Richards thomir at gmail.com
Mon Aug 10 08:06:06 PDT 2009


Hi,

I'm trying to write an application that monitors the active sessions
an X11 server is handling. Essentially I need to get a list of display
names, and then connect to them using XOpenDisplay. Essentially I need
to monitor all active X11 sessions and do things like take snapshots
of application windows running within those sessions.

So far I haven't seen any API to do this - all the XLib API functions
I can see require that you have already connected to the display. I
have come up with a few hacky methods. The first is to scan the X
server lock files in /tmp/, which gives me the process Id, then to
check the command line args of the process to determine the display
name (I realise that this method has several obvious flaws). Another
method is to look in the utmp records, but then I miss the entry for
the X session that runs the graphical login screens (such as KDM).

Can anyone suggest a more suitable method of monitoring active X11 sessions?

Cheers,



More information about the xorg mailing list