#include #include #include #include #include /* Compile with "gcc -o skip_taskbar -Wall skip_taskbar.c -lX11" */ /* Run as ./skip_taskbar [0|1] to select initial state */ /* Click middle mouse button on window to toggle */ /* Set window state hint to skip taskbar or not */ static void SetSkipTaskbarHint(Display* display, Window win, Bool toggle) { fprintf(stderr, "Setting hint to %s on taskbar 0x%x\n", (toggle ? "hide" : "show"), (unsigned int)win); Atom skip_taskbar = XInternAtom(display, "_NET_WM_STATE_SKIP_TASKBAR",False); Atom net_wm_state = XInternAtom(display, "_NET_WM_STATE",False); if (toggle) { XChangeProperty(display, win, net_wm_state, XA_ATOM, 32, PropModeReplace, (unsigned char *)&skip_taskbar, 1); } else { XDeleteProperty(display, win, net_wm_state); } } int main(int argc, char** argv) { if (argc != 2 || strcmp(argv[1], "-h") == 0) { fprintf(stderr, "Usage: %s [show_on_taskbar]\n", argv[0]); return 1; } Display* display = XOpenDisplay(NULL); if (!display) { fprintf(stderr, "Couldn't open display\n"); return 1; } int screen = DefaultScreen(display); const int width = 300, height = 200; unsigned long black = BlackPixel(display, screen); unsigned long white = WhitePixel(display, screen); Window win = XCreateSimpleWindow(display, RootWindow(display, screen), 0, /* x */ 0, /* y */ width, height, 0, /* border_width */ black, /* border */ white); /* background */ Bool toggle = (strcmp(argv[1], "0") != 0); SetSkipTaskbarHint(display, win, toggle); XSelectInput(display, win, ButtonPressMask); XMapWindow(display, win); while (1) { XEvent event; XNextEvent(display, &event); if (event.type == ButtonPress) { XButtonEvent be = event.xbutton; if (be.button == 2) { toggle = !toggle; SetSkipTaskbarHint(display, win, toggle); } } } return 0; }