Please bear with us as we work to restore functionality to dotfiles.org.
One of the resource configurations depends on this.
#include
#include
#include
#include
#include
#include
void
read_input(int argc, char **argv, unsigned char *buf, size_t buf_size)
{
int i;
memset(buf, '\0', sizeof buf_size);
if (argc > 1) {
int j, k;
for (k = 0, i = 1; i < argc; i++) {
for (j = 0; (k < (int) buf_size)
&& (j < (int) strlen(argv[i])); j++, k++)
buf[k] = argv[i][j];
buf[k++] = ' ';
}
} else {
int c;
i = 0;
while ((i < (int) buf_size) && ((c = getchar()) != EOF)) {
if (c == '\n')
continue;
buf[i++] = c;
}
}
}
int
set_focused_wmname(unsigned char *title, size_t title_len)
{
Display *display;
Window window;
XTextProperty text_prop;
int unused_revert_to_return;
if (!(display = XOpenDisplay(getenv("DISPLAY"))))
return -1;
XGetInputFocus(display, &window, &unused_revert_to_return);
text_prop.value = title;
text_prop.encoding = XA_STRING;
text_prop.format = 8;
text_prop.nitems = title_len;
XSetWMName(display, window, &text_prop);
XFlush(display);
XCloseDisplay(display);
return 0;
}
int
main(int argc, char **argv)
{
unsigned char title[1024];
read_input(argc, argv, &title, sizeof title);
if (set_focused_wmname(title, sizeof title) == -1)
exit(EXIT_FAILURE);
exit(EXIT_SUCCESS);
}