API for finding out whether your X monitor is on the current VT

Tim Dijkstra newsuser at famdijkstra.org
Mon Jun 19 07:52:19 PDT 2006


On Sun, 18 Jun 2006 16:39:41 +1000
"Dave Airlie" <airlied at gmail.com> wrote:

> > I've been looking, without success so far, for an existing extension
> > + API that'll allow me to find out whether my X session is on the
> > current VT (Virtual Terminal) ?


> > In other words, on a computer with many concurrent X sessions (or an
> > active console user), is my X session currently being displayed and
> > so will likely to get the user's attention?
> >
> >
> > I'd appreciate any pointers. I can envision a way to do this that'll
> > work on a local machine and require root (to access /dev/console),
> > but I'd rather avoid that.

I was trying the same thing... The best (not really portable)
suggestions I so far got for finding the VT we belong to, where using
DISPLAY or greping through the logs.

And yes, you can get the current VT with the VT_GETSTATE ioctl, but
indeed you need the console for that.

> You should be able to use the root window property XFree86_VT and the
> Linux fgconsole command to do it, not sure how to do it for remote
> clients, as calling fgconsole isn't probably possible.

Excuse my ignorance, but how can you get this property? With 
'xprop -root XFree86_VT'? That doesn't seem to work here.

BTW, I was looking for this because gnome-volume-manager was not
working correctly with multiple Xsessions. The devs didn't like ugly
non-portable hacks and wanted to integrate a solution in
hal/dbus/whatever (see http://bugzilla.gnome.org/show_bug.cgi?id=324159
for some discussion).

For me this was fixed by getting a laptop for my wife;)

grts Tim



More information about the xorg mailing list