On what VT am I?

Tim Dijkstra newsuser at famdijkstra.org
Thu Feb 2 13:53:12 PST 2006


On Thu, 02 Feb 2006 11:56:51 -0500
Chris Tyler <chris at tylers.info> wrote:

> > I have a setup with different users having X sessions on several
> > virtual terminals. I want a certain app to know if it belongs to
> > the current virtual terminal or not. Now I know how to query the
> > console to ask which is the active virtual terminal. I can't figure
> > out however how to ask the xserver on which VT it runs. I can get
> > the display string of course. And although usually vt(7+n) == :n
> > this isn't guarantied.
> 
> On Linux the VT of $DISPLAY is:
> 
> fuser /dev/tty* 2>&1|egrep "\<$(ps aux|egrep "X(org)? .*$(echo
> $DISPLAY| cut -d. -f1)\>"|awk '{print $2}')\>"|cut -d: -f1

OK thanks, this seems to work on my system, but seems a bit fragile...
For example: does X always have the display on the cmdline?

grts Tim
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://lists.x.org/archives/xorg/attachments/20060202/76b44b38/attachment.pgp>


More information about the xorg mailing list