For X11 I can start applications from the Linux console or via SSH (or shell scripts, etc.) with
DISPLAY=:0 application
And may need to make sure the application finds the authentication files or use commands like xhost.
But how do I start Wayland programs from outside the Wayland session? I only found information on how to start Wayland compositors from the console, but no hint how to start applications inside a Wayland session and how to select which session is used, if there are more than one.
X11 equivalent:
I want to start a program inside an existing session.
- I am logged in, e.g., using lightdm into a KDE or GNOME session.
- My user has access to the corresponding X11 cookies.
- I switch to a Linux console, e.g., by pressing Ctrl-Alt-F3
- I run
DISPLAY=:0 xmessage "Hello!" - I switch back to the X11 session, e.g., by pressing Ctrl-Alt-F7 when the X-Server is using on VT 7.
- I see the xmessage dialog and can interact with it.
This works for every X11 program as the programs behave like they were started from a terminal emulator, only that the DISPLAY variable is not set automatically on a Linux shell like it is in a X11 session.
After defining the DISPLAY variable, the programs use the same unix sockets and other IPC mechanisms as the programs that were started in the X11 session and do not have to know about not being started from a graphical application.