User Tools

Site Tools



Configure a Program to Auto-Start

Configure an X Program to Auto-Start (e.g. Mono)

From the ComfilePi desktop:

  1. Run the command lxsession-default-apps. If it is not installed, run the command sudo apt-get install lxsession-default-apps.
  2. Choose the Autostart option.
  3. In the Manual autostarted applications section, uncheck all existing applications.
  4. Enter the command necessary to start your program (e.g. mono HelloWorld.exe) and press the Add button.

After rebooting the ComfilePi, only your program will appear. To get back to a desktop environment:

  1. Close your application. You'll see only black.
  2. Right-click (you may need to connect a mouse) anywhere in the black space and a context menu will appear.

  1. Choose the Terminal emulator option.
  2. Run the command lxsession-default-apps and restore the original settings.
  3. Run the reboot command to reboot the ComfilePi and the ComfilePi will reboot to the original desktop environment.

Configure a non-X Program to Auto-Start (e.g. Qt EGLFS)

Most embedded applications do not run in a desktop environment. This procedure will describe how to configure the ComfilePi to boot to a console instead of a desktop environment, and auto-start a program as a service.

Configure the ComfilePi to Boot to a Console

  1. From a console/terminal, execute the command sudo raspi-config.
  2. Select 3 Boot Options –> B1 Desktop / CLI –> B1 Console.

  3. Then select Finish to exit, and “Yes” to reboot.

After rebooting, instead of booting to the desktop environment, it will boot to a console waiting for user to login.

Register a Program to Auto-Start

  1. Create a {program_name}.service file in your favorite text editor, and copy it to /etc/systemd/system/. For this demonstration we will create a file named dashboard.service that will run the dashboard example program at /opt/Qt5.8/examples/quickcontrols/extras/dashboard.
  2. Edit the file with the following contents
    Description=Dashboard example program

    * Description is just a textual description of the service.
    * ExecStart is the path to the executable to run.
    * Restart=always will cause the program to respawn if/when its exited.
    * WantedBy establishes where in the execution pipeline to this program should execute.
    * See the systemd official documentation for more information.

  3. Register the service by executing sudo systemctl enable dashboard.service, and the next time the ComfilePi boots, it will run the dashboard program automatically. Execute sudo systemctl start dashboard.service to run the service immediately.


  • sudo systemctl enable dashboard.service - Register the service. The program will auto-start on the next boot.
  • sudo systemctl disable dashboard.service - Unregister the service. The program will no longer auto-start.
  • sudo systemctl start dashboard.service - Start the program immediately.
  • sudo systemctl stop dashboard.service - Stop the program immediately. It will not automatically respawn after executing this command even with the Restart=always option.

Environment Variables for Qt EGLFS Programs

Qt programs running with the EGLFS backend need to declare a few environment variables to work properly. They are currently set in /etc/profile.d/, so if running the program under a user's profile, nothing needs to be done. However, systemd will not be running under a normal user's profile, so the environment variables must be set explicitly in the .service file as illustrated below.

comfilepi/configure_a_program_to_auto-start/index.txt · Last modified: 2018/06/22 09:33 by COMFILE Technology