1

I have a remote Raspberry Pi connected to an old display. The Raspberry Pi is not configured correctly to display to this old display (it is basically sending the wrong resolution signal to the display). I need to troubleshoot this while the old display is connected to the Raspberry Pi.

To do this, I have connected via SSH (with X11 forwarding enabled) to the Raspberry Pi. I now need to send xrandr (and similar commands) to the Raspberry Pi and to have those commands apply to the remote X11 session running on the Raspberry Pi, as opposed to the X11 session running on my local computer.

When I run xrandr -q, xrandr -s 640x480 etc. in the terminal while connected via SSH to the Raspberry Pi, the commands apply to the local X11 session when I need them to apply to the remote X11 session. How can I do this?

2 Answers 2

2

you could set the HDMI-mode (resolution + frequency) via config.txt:

Please see this content on the original Raspberry OS documentation:

And then reboot the Raspberry Pi. With the HDMI-modes you can even override the EDID-information.

2
  • Thanks very much for your suggestion. I've tried saving the lines framebuffer_width=640 and framebuffer_width=480 to /boot/config.txt but this has not worked. So the question is how to access the remote X11 session to troubleshoot with the old monitor attached from boot (which means that the monitor cannot be read, as it is set to the wrong configuration). Nov 21, 2022 at 1:35
  • I had thought of something like hdmi_group=2 and hdmi_mode=9 for a resolution of 800x600 at 60Hz. -> put this into config.txt Link: raspberrypi.com/documentation/computers/…
    – ppuschmann
    Apr 4, 2023 at 12:50
1

When I run xrandr -q, xrandr -s 640x480 etc. in the terminal while connected via SSH to the Raspberry Pi, the commands apply to the local X11 session

According to your comment this is because you are using ssh -X. If you don't need to do that, don't, it simplifies things (you could also run two ssh connections, only one with -X).

Sans -X, trying xrandr in an ssh session would result in:

> xrandr
Can't open display 

To get around that, you need to know which display to target. If there is only one, this should work:

> export DISPLAY=:0
> xrandr ...

If that doesn't work or you aren't sure, from inside the X session, try echo $DISPLAY, and use that value instead.

If you really need to do this inside a -X sesssion, in which $DISPLAY is set to refer back to the origin host, try:

(export DISPLAY=:0; xrandr ...)

The () runs the commands in a subshell, in which environment variables can be changed without it applying back up the process tree. Since it sounds like you have a static set of xrandr ops you want to execute, you could put them all in a script and put export DISPLAY=:0 at the top, which accomplishes the same thing (it will only apply in that script and to anything the script starts).

2
  • Thanks very much for your comment, which helps to think about the issue. When connecting via ssh, the xrandr response is Can't open display, as you mentioned and $DISPLAY holds no numerical value. When connecting via ssh -X, $DISPLAY holds the value localhost:10.0. That I think indicates that the local system is issuing commands to the local X11 system (which, by -X is receiving instructions from the remote machine on what to draw locally). So the question is how to issue commands to the remote X11 system, which would have $DISPLAY with a value :0. Nov 21, 2022 at 1:32
  • Okay, I've never used ssh -X and was unaware of this. I added some things to the answer to work around that.
    – goldilocks
    Nov 21, 2022 at 16:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.