Today's Deals (in Amazon.com)

 Question:

remote - Start local application with GUI, over ssh
  • Adrian

    i have a raspberry pi, connected to HDMI monitor.

    I am trying to run a simple gui (created in qt), and i'm using mpi library for interprocess communication. I want to get this application working on raspberry pi, and on my laptop using something like this

    $ mpiexec -f machinefile -n 2 ./mpi_gui
    

    where the machinefile contains the ip addresses for my pi, and for the laptop.

    I am following this tutorial. The thing is that this communication is over ssh and i get an "cannot connect to x server" error. I tried

    $ mpiexec -enable-x -f machinefile -n 2 ./mpi_gui
    

    to get the raspberry pi gui on my laptop, and it works ok.

    Is it possible to run the gui of the raspberry pi on the hdmi monitor to which is connected ?

    Later edit:

    I don't know if i explained well what i want to obtain. I want the process running on the raspberry pi to put the gui on the HDMI monitor connected to it. And the process running on my laptop, to output the gui on the laptop's monitor.

    But i can't see how this can be achieved.

    1) Using ssh to connect to pi, i enter the command:

    sh-4.2$ ssh [email protected]
    [email protected]'s password: 
    pi@raspberrypi ~/mpi_testing/mpi_with_gui/mpi_with_gui/mpi_gui $ DISPLAY=:0 mpiexec -n 2 ./mpi_gui
    Greetings from process 0 of 2!
    Greetings from process 1 of 2!
    

    This starts both processes on the raspberry, both gui's are displayed on the hdmi monitor connected to pi. (not what i want)

    2) I run on my laptop the command bellow:

    sh-4.2$ mpiexec -n 2 ./mpi_gui
    Greetings from process 0 of 2!
    Greetings from process 1 of 2!
    

    Both processes are running on my laptop, as expected, i got those 2 gui's on the laptop's display.(still, not what i want)

    3) I run from my laptop the command below:

    sh-4.2$ DISPLAY=:0 mpiexec -f machinefile -n 2 ./mpi_gui
    [email protected]'s password: 
    mpi_gui: cannot connect to X server
    

    It would be nice to start the laptop process with the gui displayed on the laptop's screen, and the raspberry pi process with the gui displayed on its hdmi screen. Though, there should be a way to tell mpiexec that each process should use it's own X server (or is this ssh job?)

  •  Answers:

  • Arne

    First of all, you should be able to access your Pi via its hostname, like raspberrypi.local. Second, you should make an entry in your .ssh/config file for the Pi:

    Host raspberrypi
       User pi
       Hostname raspberrypi.local
       Compression yes
       ForwardX11 yes
    

    This will enable X11 forwarding for the host with hostname raspberrypi.local (replace with IP if you like). It also enables compression, which is a good idea for X11. You could also specify an RSA key here for authentication, so you don't have to type a password.

    Edit: To actually don't have the X11 connection forwarded, but to instead use the local X server, you can do the following: First, you have to run xhost +local: on your Raspberry Pi (not via ssh). Second, you have to set the display variable for your remote command to DISPLAY=:0 you can test this by running ssh interactively:

    ssh [email protected] 'DISPLAY=:0 name-of-program-to-run'