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

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:

Description = Onyx Service
After = weston.service
Type = forking

ExecStart = /bin/bash /opt/onyx-start

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.

2 Answers 2


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:

. /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.)

  • 1
    This is awesome. Worked! In my case the file was /etc/profile.d/weston.sh. Thanks for the answer! Jan 30, 2019 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, 2019 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. Jan 30, 2019 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, 2019 at 11:46
  • When I have more details, I'll add. Thanks still. Jan 30, 2019 at 11:46

To add to the answer of @filbranden, /etc/profile.d/weston.sh or wayland_env.sh is no longer distributed, so what worked for me was the following script:

weston &
sleep 5s # could be less
export WAYLAND_DISPLAY=wayland-0
export DISPLAY=:1
exec /path/to/myapp

  • Do you know how to get rid of that sleep? I have been investigating that but not been successful finding a working solution yet. Oct 10, 2020 at 9:37
  • So, my script was a login script that you could select on the login page and had to start weston. But maybe if you get it started with a service then you don't have to start weston in the script, and thus get rid of the sleep?
    – cengique
    Oct 11, 2020 at 14:49
  • Unfortunaley weston service does not notify. Oct 11, 2020 at 15:22

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.