how to list active X11 sessions on a local machine?

Colin Guthrie gmane at colin.guthr.ie
Mon Aug 10 08:40:43 PDT 2009


'Twas brillig, and Thomi Richards at 10/08/09 16:06 did gyre and gimble:
> 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?

Does console-kit supply the necessary info here?

See ck-list-sessions.

Relies on the user's session being properly registered with console kit 
to work but that should be the case for other things anyway.

HTHs

Col

-- 

Colin Guthrie
gmane(at)colin.guthr.ie
http://colin.guthr.ie/

Day Job:
   Tribalogic Limited [http://www.tribalogic.net/]
Open Source:
   Mandriva Linux Contributor [http://www.mandriva.com/]
   PulseAudio Hacker [http://www.pulseaudio.org/]
   Trac Hacker [http://trac.edgewall.org/]




More information about the xorg mailing list