Linux X11 – Global Keyboard Hook

Try compile easy code from this page: http://webhamster.ru/site/page/index/articles/comp/367 It’s sample of get global keyboard event. This small app working as xinput. Remark 1: Write device ID to mian.cpp (get ID by running xinput without parameters): sprintf(deviceId, “9”); Remark 2: Compile command: gcc ./main.cpp -lstdc++ -lX11 -lXext -lXi Remakr 3: Before compile, install libxi-dev package: apt-get … Read more

How to run an X program from outside the X session (e.g. from the console or SSH) [closed]

The short answer is that you have to set the DISPLAY environment variable, and then the app will run. The long answer is that we’ve got Xauth, and unless you’re running as the same user on the same machine that’s probably not going to work unless you export the Xauth credential from the account running … Read more

GTK implementation of MessageBox

Hmm, ok. I’d suggest code like this, then: typedef struct { int type; int result; } DialogData; static gboolean display_dialog(gpointer user_data) { DialogData *dialog_data = user_data; GtkWidget *dialog; if (dialog_data->type & MB_YESNO) dialog = gtk_message_dialog_new(…); else dialog = gtk_message_dialog_new(…); // Set title, etc. dialog_data->result = gtk_dialog_run(…); gtk_main_quit(); // Quits the main loop run in MessageBox() … Read more

OpenGL without X.org in linux

Update (Sep. 17, 2017): NVIDIA recently published an article detailing how to use OpenGL on headless systems, which is a very similar use case as the question describes. In summary: Link to libOpenGL.so and libEGL.so instead of libGL.so. (Your linker options should therefore be -lOpenGL -lEGL Call eglGetDisplay, then eglInitialize to initialize EGL. Call eglChooseConfig … Read more

Run X application in a Docker container reliably on a server connected via SSH without “–net host”

I figured it out. When you are connecting to a computer with SSH and using X11 forwarding, /tmp/.X11-unix is not used for the X communication and the part related to $XSOCK is unnecessary. Any X application rather uses the hostname in $DISPLAY, typically “localhost” and connects using TCP. This is then tunneled back to the … Read more