Fix segfault on systems with broken locale support --- dmenu.c.orig 2013-11-16 10:52:03.970786705 -0300 +++ dmenu.c 2013-11-18 16:07:45.422148846 -0300 @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include @@ -590,7 +591,13 @@ CWOverrideRedirect | CWBackPixel | CWEventMask, &swa); /* open input methods */ - xim = XOpenIM(dc->dpy, NULL, NULL, NULL); + if (!(xim = XOpenIM(dc->dpy, NULL, NULL, NULL))) { + fputs("dmenu: Failed to open input method\n", stderr); + /* Might be an issue with the locale */ + setlocale(LC_ALL, "C"); + if (!(xim = XOpenIM(dc->dpy, NULL, NULL, NULL))) + exit(1); + } xic = XCreateIC(xim, XNInputStyle, XIMPreeditNothing | XIMStatusNothing, XNClientWindow, win, XNFocusWindow, win, NULL);