On what VT am I?

Chris Tyler chris at tylers.info
Fri Feb 3 06:31:40 PST 2006


> > > 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?
> 
> No.

[a] It will if it's started by gdm/xdm/kdm in most configurations.
[b] If it doesn't, it's display :0 and the script could be modified to
take that into consideration.

But here's another approach...

sed -n "s/.*VT number \([0-9]*\).*$/\1/p" $(xset q|sed -n "s/.*Log file:
*\(.*\)$/\1/p")

Should work on non-Linux boxen, haven't tested it on such.




More information about the xorg mailing list