Auto run GTK app on Colibri iMX6ULL using yocto

Hi,
I am using yocto for application development on colibri iMX6ULL. I want to auto launch my application developed using gtk. I have gone through the link How to Autorun Application at the Start up in Linux | Toradex Developer Center.
Can any one guide me to a link that gives me details on how to auto launch my GTK UI app using wayland-app-launch?
Thanks and happy new year.

Hi, I’m the Toradex AI Assistant. The Toradex Support team will follow up with you shortly!

Did you like my answer?

:+1: :-1:


Hello,

To automatically launch your GTK application on a Colibri iMX6ULL using Yocto, you can utilize the systemd service manager, which is part of the Toradex Linux BSP. Here’s a general approach:

  1. Create a Systemd Service File: This file will define how your application should be started. Create a file with a .service extension, for example, myapp.service, and place it in /etc/systemd/system/.

    Example content for myapp.service:

    [Unit]
    Description=Start My GTK Application
    After=weston.service
    
    [Service]
    ExecStart=/path/to/your/gtk/application
    Environment="XDG_RUNTIME_DIR=/run/user/1000"
    Environment="DISPLAY=:0"
    
    [Install]
    WantedBy=multi-user.target
    

    Ensure that the ExecStart path points to your GTK application.

  2. Enable the Service: Use the systemctl command to enable your service so that it starts on boot:

    sudo systemctl enable myapp.service
    sudo systemctl start myapp.service
    
  3. Using wayland-app-launch: If you prefer to use wayland-app-launch, you can modify the ExecStart line in your service file to include it. For example:

    ExecStart=/usr/bin/wayland-app-launch /path/to/your/gtk/application
    

    This assumes that wayland-app-launch is available in your environment and that your application is compatible with Wayland.

This setup should help you automatically start your GTK application on boot. If you have any further questions about integrating wayland-app-launch, feel free to ask!

Best regards,
Toradex AI Assistant

Please, also check if these links can help you solve your problem:

Autostart GTK application after boot.

I need this auto launch of gtk app for production where I will not be able to add a service to systemd. The best way will be that I build an image based on the reference multimedia image that will automatically lauch my gtk app which is installed in /usr/bin, on boot. I have seen that wayland-app-launch is use in tdx-reference-multimedia-image to launch the analog clock application. Is there a similar way to build my custom image to launch the gtk app on boot? Thanks for your help.

Hi @mansijc !

You can create (copy) a similar recipe like wayland-app-launch (https://git.toradex.com/cgit/meta-toradex-demos.git/tree/recipes-graphics/wayland-app-launch?id=#n
) and adjust it for your usage.

Checking the structure of the recipe, you will see that the service will be adapted according to the variables defined in the .bb file, which will be used in the .inc file in there.

Best regards,

Thanks a lot for your reply. Let me do this and get back to you. Regards,