How to run a single X11 application on a Raspberry PI?

I've got a RPI4 with a DSI touch display. I've installed lxde but I don't want to use it. Instead I would like to start a single app in full screen mode.

I currently interact with my device through SSH.

What I tried is to stop lxde and naïvely start an app:

# service stop lxde
# xeyes
Error: Can't open display: localhost:10.0

Starting again lxde I notice it runs over xorg

# ps -axu | grep xorg
# root      1397  0.4  0.5 127712 46884 tty7     Ssl+ 16:38   
            0:01 /usr/lib/xorg/Xorg :0 vt07 -nolisten tcp -novtswitch -auth 
            /var/run/lxdm/lxdm-:0.auth

I suppose then I need to run my app through some wrapper, but I don't really understand how to do it.

How can I run xeyes in fullscreen mode from my ssh remote?

In the end I would like to run a Qt app started as a service after the boot:

import sys
import PyQt5
from PyQt5.QtWidgets import *

import mainwindow_auto

class MainWindow(QMainWindow, mainwindow_auto.Ui_MainWindow):
    def pressedOnButton(self):
        print ("Pressed On!")

    def pressedOffButton(self):
        print ("Pressed Off!")

    def __init__(self):
        super(self.__class__, self).__init__()
        self.setupUi(self) # gets defined in the UI file

        self.btnOn.clicked.connect(lambda: self.pressedOnButton())
        self.btnOff.clicked.connect(lambda: self.pressedOffButton())

def main():
    app = QApplication(sys.argv)
    form = MainWindow()
    form.show()
    sys.exit(app.exec_())

What would be the starting point for this?


I don't think the error you saw is actually relevant to what you want to achieve. localhost:10.0 indicates that it's trying to make use of X11 Forwarding to make itself show on your SSH client, probably because you have enabled it on the server and is using -X or equivalent client conf. So first of all to make it use a local X server, either ssh without -X (or, use -x to disable it explicitly) or use an appropriate DISPLAY environment variable when you run the program (e.g. DISPLAY=:0 xeyes).

As for your "real" question, you'll need an Xorg server running on the Pi itself anyway if you want to have the program show itself on the DSI display. To do that you could make the program as the main/only client of the server with xinit / startx. However, AFAIK it's a bit tricky to do remotely (if possible at all) because of the tty stuff and so on.

With that said, you can see if these fit for your use case:

  1. https://wiki.archlinux.org/title/Getty#Automatic_login_to_virtual_console
  2. https://wiki.archlinux.org/title/Xinit#Autostart_X_at_login

P.S. I'm not sure if the DE/WM-less approach will guarantee that the program will run in fullscreen. (I'm not familiar enough with the internals of X to tell whether or not you need to do something in your program to make that happen.) Anyway, you can consider using a lightweight WM that allows you to start a program in fullscreen upon its startup.