(Linux) How to Run a Program of Gtk Without Display Environment? Gtk-Warning **: Cannot Open Display:

(Linux) How to run a program of gtk without display environment? Gtk-WARNING **: cannot open display:

The ssh utility has an option -X which enables X11 forwarding.

Have you tried to connect to your destination like that ?

Or the other option is to perform the export DISPLAY=:0.0 after you log-in to your host, then run your app.

This way you'll save some network traffic, will run your app remotely, but the GUI will be displayed on the screen of the remote host.

P.S. Generally speaking your application logic might be invalid if it fails to run GUI.
Are you sure that your application will do the expected stuff when it fails to run the GUI ?

VS Code not opening with bash shell - (code:222398): Gtk-WARNING **: 13:20:07.940: cannot open display:

Your DISPLAY environment variable is not being set. Are there some settings from the many csh startup files you forgot to replicate into the bash startup (~/.bash_profile)?

Just as an aside, I am extremely curious what kind of Linux distribution both uses tcsh by default AND neglects to maintain the POSIX shell profile.

Flatpak on wayland error cannot open display:

The problem seems to be that GDK_BACKEND variable is for some reason set to X11. Run following commands to check whether you have the same problem. I'm using gnome maps, but you can use whichever app you like.

flatpak run --command=sh org.gnome.Maps
echo $GDK_BACKEND:$WAYLAND_DISPLAY:$DISPLAY

Your output should be something like wayland-0,x11:wayland-0,:0.0. If it's not you should try experimenting with those variables

export GDK_BACKEND="wayland,x11"
export WAYLAND_DISPLAY="wayland-0"
export DISPLAY="wayland-0"
gnome-maps

Variable changes aren't permanent and are set only until container's shell is closed.

Using GTK without DISPLAY

There is an X server called Xvfb which provides a valid DISPLAY and sends the output to a file instead of to graphics hardware. You can run that on the same machine that's running your gtk client, and gtk will be able to do whatever it wants to do without using any of your network bandwidth. As a bonus, you can read Xvfb's output buffer from the file, allowing you to get a screenshot of what would be on the screen.

GtkWarning: could not open display

First of all, you didn't specify if you have a desktop environment (or X) installed on your server?

Regardless of that, you can achieve headless setup for your spider by using xvfb:

Xvfb or X virtual framebuffer is a display server implementing the X11
display server protocol. In contrast to other display servers Xvfb
performs all graphical operations in memory without showing any screen
output. From the point of view of the client, it acts exactly like any
other X display server, serving requests and sending events and errors
as appropriate. However, no output is shown. This virtual server does
not require the computer it is running on to even have a screen or any
input device.

First, install xvfb on your server. Assuming you are using apt-get:

sudo apt-get install xvfb

Now, run the xvfb service at a custom display number, like:

sudo Xvfb :5

After that, you can run any application that requires X inside your virtual frame buffer by exporting the display number and running your application:

export DISPLAY=:5
run_my_application

The DISPLAY is set only for the current terminal session, so keep that in mind when implementing automation for this step.

symfony + knp_snappy : gtk-WARNING cannot open display

The point was that the requested URL was behind a firewall, so wkhtmltopdf was recieving a 302 access denied.

For knp_snappy users facing the same problem, the solution is really well explained here and here.

Hope that helps!



Related Topics



Leave a reply



Submit