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).
xrandr -display :0.0
? It works here. – Rmano Jan 19 '16 at 20:39xhost +
on the X server? – Rmano Jan 19 '16 at 21:16xrandr
will still work because it can access the display socket in/tmp/.X11-unix/
– bain Jan 20 '16 at 19:00