The situation is as follows.
I have a multiuser desktop machine with Debian Linux 6.0 and an ATI videocard with one monitor connected. I have root access to it. There can be several KDE sessions started, like this:
$ w 21:51:30 up ? days, 4:22, ? users, load average: 1.72, 1.68, 1.67 USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT u1 pts/0 :0 Sat18 4days 0.00s 11.68s kdeinit4: kded4 [kdeinit] u2 pts/5 :1 Mon17 2days 0.00s 6.65s kdeinit4: kded4 [kdeinit]
So, two virtual terminals are in use, tty7 and tty8:
$ ps aux|grep /usr/bin/[X] root 2944 3.1 12.4 670040 1019904 tty7 Ss+ Aug27 187:52 /usr/bin/X :0 vt7 -br -nolisten tcp -auth /var/run/xauth/A:0-?????? root 5507 0.9 3.7 425136 309676 tty8 Ss+ Aug29 29:38 /usr/bin/X :1 vt8 -br -nolisten tcp -auth /var/run/xauth/A:1-??????
But of course only one of them is active at any given moment, i.e. displayed on the monitor. Someone sitting at the keyboard can switch between them using Ctrl+Alt+F
So, I connect via ssh from a remote host. I need to know which X DISPLAY is active now. Is it possible? I have googled all over the place and can't find the answer.