Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using GTK without DISPLAY

Tags:

c++

c

gtk

Is it possible to use GTK without a valid X display?

I want to use GTK with Webkit, but for now I'm only interested in using the DOM functions to experiment, so I have no need to actually display anything. It's very convenient for me to do this over an SSH connection on a server that has no display.

But, without a DISPLAY environment variable, gtk_init() simply fails with the message:

Gtk-WARNING **: cannot open display:

Is there anyway to use GTK without a display?

like image 386
Channel72 Avatar asked Jul 27 '12 19:07

Channel72


1 Answers

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.

like image 80
Alan Curry Avatar answered Oct 09 '22 01:10

Alan Curry