2

I would like to launch a Qt application on start up. The application uses some of the features from weston/wayland desktop, so it should be launched on top of weston, right after weston is started. Normally, I work with SSH to connect to the target platform and launch the application using following commands:

systemctl stop weston
weston --tty=1
./QtApp

If I do not kill the weston and do not start it with a TTY, I get the following error:

Failed to create display

What I have tried to do is to set up a start up script and integrate it into the systemd:

[Unit]
Description = Onyx Service
After = weston.service
Type = forking

[Service]
ExecStart = /bin/bash /opt/onyx-start

[Install]
WantedBy = multi-user.target

However, as you can guess, this does not work. I need to manage to start an application on an existing weston instance that is not started with a TTY option.

1

Typically it's not about starting Weston on a specific tty, but about having the environment variables set which will route you to the proper instances of Wayland and Weston. These variables are such as WAYLAND_DISPLAY and even DISPLAY for applications that need XWayland.

You can typically get the proper environment you need by sourcing a file such as /etc/profile.d/weston.sh (or wayland_env.sh in some cases.) This is typically done for you when you log in to a shell, but systemd jobs do not launch a shell, so they don't get these variables set.

Maybe try something like this in onyx-start:

#!/bin/sh
. /etc/profile.d/weston.sh
exec /path/to/QtApp

The service unit you have should work with that.

(If it still doesn't work, please list more details about your environment, such as the Linux distribution you're using, contents of weston.service, output of systemctl status weston.service, contents of weston.sh or wayland_env.sh and wether starting QtApp works through SSH without launching a new Weston, perhaps after sourcing the environment profile file, if for any reason those variables aren't being set on those connections.)

  • This is awesome. Worked! In my case the file was /etc/profile.d/weston.sh. Thanks for the answer! – mozcelikors Jan 30 at 11:22
  • That's great @mozcelikors! I updated the answer to refer to weston.sh instead. Really glad this solved it for you! – filbranden Jan 30 at 11:38
  • I think I spoke too soon and misjudged it. weston.sh only creates XDG_RUNTIME_DIR. This unfortunately did not help running an app on weston. I might have started the daemon with weston --tty=1 when I had success. – mozcelikors Jan 30 at 11:44
  • Hmmm ok no worries... Keep looking (if you have time) and update the question with more details, I'll keep trying to help you. – filbranden Jan 30 at 11:46
  • When I have more details, I'll add. Thanks still. – mozcelikors Jan 30 at 11:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.