/* * A simple example of setting the XUrgencyHint on an xterm from a program * running in it. Compile with: * * gcc -L/usr/X11R6/lib -lX11 urgent.c -o urgent * */ #include #include #include #include static int set_urgency(Display *dpy, Window id, int set) { XWMHints *hints=XGetWMHints(dpy, id); if(hints==NULL) return 0; if(set) hints->flags|=XUrgencyHint; else hints->flags&=~XUrgencyHint; return (XSetWMHints(dpy, id, hints)!=0); } int main(void) { Display *dpy; const char *ids; Window id; ids=getenv("WINDOWID"); if(ids==NULL){ fprintf(stderr, "WINDOWID not set."); return EXIT_FAILURE; } id=atoi(ids); dpy=XOpenDisplay(NULL); if(dpy==NULL){ fprintf(stderr, "Unable to open display."); return EXIT_FAILURE; } /* Set the flag */ if(!set_urgency(dpy, id, 1)){ XCloseDisplay(dpy); fprintf(stderr, "Unable to set urgency."); return EXIT_FAILURE; } XFlush(dpy); /* Wait for a keypress */ getchar(); /* Unset the flag */ if(!set_urgency(dpy, id, 0)){ XCloseDisplay(dpy); fprintf(stderr, "Unable to unset urgency."); return EXIT_FAILURE; } XFlush(dpy); XCloseDisplay(dpy); return EXIT_SUCCESS; }