2

If I run xrandr from a terminal in the X session I can see the names of different outputs available on the system. For example, I get something like this:

Screen 0: minimum 320 x 200, current 1440 x 900, maximum 8192 x 8192
VGA disconnected (normal left inverted right x axis y axis)
LVDS connected (normal left inverted right x axis y axis)
    1440x900       59.9*+
    1280x854       59.9  
    1280x800       59.8  

That's great, but it only works if I am on the X session either physically in front of the computer or via Remote Desktop (VNC). How can I get these same names remotely via SSH instead? I probably wouldn't be using xrandr for it, but then what should I use?

With the above example, what I would like to get from SSH is the "VGA" and "LVDS" values.

user195574
  • 21
  • 1
  • 2

2 Answers2

2

If you connect through ssh, you could very well not even having an X session running. Even if you have it, the ssh session is not connected to any of them by default... you can even login via ssh to an user different from the one that has the X session opened.

So for example if I ssh to my remote machine I have:

(0)pern:~% xrandr --current
Can't open display 

So I have to find if an X session is running and who is connected:

(0)pern:~% w
 01:57:06 up 10 days,  9:56,  4 users,  load average: 0.12, 0.17, 0.13
USER     TTY      FROM             LOGIN@   IDLE   JCPU   PCPU WHAT
romano   tty7     :0               08Nov13 10days  1:29m  6.95s gnome-session -
romano   pts/2    :0               08Nov13 10days 23.67s 23.67s /home/romano/bi
romano   pts/0    xxx.xx.xxx.xxx   01:56    2.00s  0.08s  0.00s w
romano   pts/3    :0               08Nov13  6:48m  0.08s  0.08s zsh

Hmmm... let's see the capability of display :0, given that I am logged as the same user and so I have the permissions:

(1)pern:~% xrandr --current -display  :0
Screen 0: minimum 320 x 200, current 1680 x 1050, maximum 8192 x 8192
DIN disconnected (normal left inverted right x axis y axis)
DVI-0 connected 1680x1050+0+0 (normal left inverted right x axis y axis) 430mm x 270mm
   1680x1050      59.9*+
   1600x1200      60.0  
   1280x1024      75.0     60.0  
   1024x768       75.1     72.0     70.1     60.0  
   832x624        74.6  
   800x600        72.2     75.0     60.3     56.2  
   640x480        72.8     75.0     66.7     60.0  
   720x400        70.1  

Notice that all this will work if the user on the non graphic session has sufficient rights to the server. Basically, it needs to be the same user that started the X server (and sometime, do to .Xauthority, not even in that case); to have it working anytime, you should do xhost + on the server (but this has big security risks).

Rmano
  • 32,167
1

I've already covered how to list displays in a previous life, that should allow you to iterate each X display and show available outputs

w -hs | awk '{print $3}' | sort -u | xargs -I% xrandr -display %

I've no idea if you need to loop displays, but that should work nonetheless.

Oli
  • 299,380