Skip to content

Instantly share code, notes, and snippets.

@mid-kid
Last active January 1, 2024 23:00
Show Gist options
  • Save mid-kid/c4eae19b20d251d2b55008e42998180f to your computer and use it in GitHub Desktop.
Save mid-kid/c4eae19b20d251d2b55008e42998180f to your computer and use it in GitHub Desktop.
Check for the presence of an Xembed tray on linux X11
#include <stdlib.h>
#include <stdio.h>
#include <X11/Xlib.h>
// Simple program to check for the presence of an Xembed tray
// Exits with status 0 if the tray exists
int main()
{
Display *d = XOpenDisplay(NULL);
if (!d) { fprintf(stderr, "XOpenDisplay failed\n"); return EXIT_FAILURE; }
Atom a = XInternAtom(d, "_NET_SYSTEM_TRAY_S0", False);
if (a == None) { fprintf(stderr, "XInternAtom failed\n"); return EXIT_FAILURE; }
Window w = XGetSelectionOwner(d, a);
if (w == None) { fprintf(stderr, "XGetSelectionOwner failed\n"); return EXIT_FAILURE; }
return EXIT_SUCCESS;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment