On a Raspberry Pi, like any Linux system, it is possible to manage multiple graphical sessions simultaneously.
X11 or X Window System is a windowing system for Unix and Linux systems that provides the foundation for the graphical user interface (GUI). It allows users to run graphical applications and manage windows on their desktop.
This can be useful for running several graphical applications in different X11 sessions (X Window System) without interfering with each other. It is also very useful when we have a Raspberry Pi in a setup with multiple screens, some of which may be “non-normal”.
For example, this is common in the case of a machine that is meant to play a video, or an application, or even a robot with a screen, where one of the screens is not a “normal” screen.
In this article, we will explore how to run a graphical application in another X11 session on Raspberry Pi and, if necessary, how to access another user’s session by importing their authentication token.
Run Application in Another Session
To run an application in another X11 session, we use the following command:
DISPLAY=:0.0 applicationName &
Here,
DISPLAY=:0.0
indicates that the application will run in the first X11 session (:0
) and on the first screen of that session (.0
).- The character
&
at the end of the command allows the application to run in the background.
Run in Another User’s Session
If we need to run the application in an X11 session that belongs to another user, we first need to import the authentication token (xauth token
) from the user who owns that session.
This is done with the following command:
xauth merge ~user/.Xauthority
In this command,
~user/.Xauthority
is the path to the other user’s.Xauthority
file, which contains the necessary information to authenticate in their X11 session.
By executing this command, we import that authentication token into our session, allowing us to run applications in the other user’s session.