V
V
Vladimir2021-02-24 18:06:59
linux
Vladimir, 2021-02-24 18:06:59

How to run an application from the terminal in the current graphical session?

There is a script that interacts with the graphical shell, but when I run it from outside, or for example through the terminal from another application, it swears at the lack of graphics, is it possible to run it already in a running environment, so that when it starts it opens in a running graphical session user. In this case, the launch command will be called through the terminal.

The background is simple, there is a python script that, if you run it just being in the environment from the terminal, starts and works.
The task is to launch it from a web server that is on the same machine, just run the launch command through exec (), in this case it falls with an error on Open_gl

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
rPman, 2021-02-24
@qDiablo

in the environment in which you launch the application, the DISPLAY variable must be defined, you can see its value in the terminal launched from the graphical environment, most likely it will be: 0 You
can use it once like this:
DISPLAY=:0.0 xclock
Also for the user, if it is different from the one for which it is launched graphical environment, it is necessary to grant rights to connect to xserver, this is done by xhost (there is also xauth ): Will give root permissions authorized to work locally with the graphical shell.
xhost +local:root
If you connect remotely using ssh, you can specify the -Y switch and then everything will be configured automatically (this can be disabled in the sshd.conf settings), i.e. I mean, from a terminal running in the xserver graphical shell (for example, xwin that comes with the cygwin package for windows), you connect to a remote server ssh -Y [email protected] and run applications there, the windows of which will be displayed locally. Not a very efficient method, but even 3d graphics will work (if the local server can). It's more efficient to use x2go for things like this.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question