On what VT am I?

Chris Tyler chris at tylers.info
Thu Feb 2 08:56:51 PST 2006


> 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

--
Chris Tyler




More information about the xorg mailing list