API for finding out whether your X monitor is on the current VT
future at shiny.co.il
Mon Jun 19 08:35:56 PDT 2006
Tim Dijkstra wrote:
> 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.
Checking the root window property works for me. As Tuuka Hastrup noted
in a private mail to me:
"At least on my X (I'm testing this with the xev command), windows get a
VisibilityNotify event state VisibilityFullyObscured when I switch away
and state VisibilityUnobscured when I switch back."
This event might allow us to know when the VT switches rather than
constantly polling for it. In my case, polling would be fine, as I need
to poll only once, to know whether to display an input dialog.
> And yes, you can get the current VT with the VT_GETSTATE ioctl, but
> indeed you need the console for that.
Getting your current VT is the real problem here. On RedHat, pam_console
gives ownership over the console to the last physically logged-in user.
> Excuse my ignorance, but how can you get this property? With
> 'xprop -root XFree86_VT'? That doesn't seem to work here.
Works for me on Xorg 7.0.
Another, GNOMEish option for finding out about VTs and their
associations might be through GDM's commands interface:
KDE might have something similar.
More information about the xorg