I have a particular need to use my Raspberry Pi as a headless system while still getting information from a GUI application. There are plenty of tutorials for using VNC or ssh with X Forwarding to accomplish this, but for my situation I needed:
- The Raspberry Pi to remain headless (not connected to a display)
- To edit and execute python scripts
- A way to see the GUI generated by those python scripts (hard to do without a display)
- Monitor the image onscreen near the headless unit (very hard to do without a display)
With these needs in mind, VNC and X11 forwarding to my stationary computer were not going to work. I found a tutorial on X11 forwarding using JuiceSSH and an X11 server app on my Android phone, but the port forwarding setup never seemed to direct it back to the device properly, and I would have had to rely on using the soft keyboard to start the python script each time anyway.
While going back through the motions of setting up X11 forwarding in PuTTY, I thought about what would happen if I forwarded to someplace other than my desktop.
As it turns out, that gave me exactly what I needed to work in my situation.
I'll walk you through how I did that:
*Disclaimer, this is geared towards windows users with android phones. As in it won't work for anybody with any other combination of devices.
- Download the X server application from Google Play .
- Once installed, open the application and wait for the blue screen to show up with your device's info.
- Open up PuTTY on your Windows machine.
- Fill in the Host Name field with your Pi's IP address.
- Configure PuTTY to forward all X11 traffic to your Android phone by entering the IP address shown after the DISPLAY= on your phone (include the display number after the colon, as shown below)
- Open the connection (or click back to the Session screen to save it as a preset) and log in to your pi.
startlxde &in the command line and wait for all of the warning messages to flood through and the Raspberry Pi's desktop to appear on your phone. In case you are wondering if/why the ampersand is important - This instructs the system to execute the command in the background. This allows you to continue typing commands even if the last one is still running.
- Run any command you want, and have the GUI appear on your phone. If the command you run has no GUI element to it, it will not show up on the screen. If the command you run has a GPU dependent GUI, it probably won't work. Here is an example of a pygame application started over SSH.
- Check out the configuration options of the X server on the Google Play page. There are steps to turn off the annoying mouse gyroscope control there. To change the screen resolution/text size, restart the app and tap on the black loading screen when prompted.
That should get you started in viewing your Raspberry Pi X session on an Android phone. The benefits of this procedure are:
- Versatility of a physical keyboard
- Access to Windows at your desk/couch/wherever
- Mobility of the display
A great guide on using PuTTY to forward X11, which this was based off of, can be found on the UT Dallas wiki.