+ n = strtol(s, &endp, 10);
+ if (errno == ERANGE || n > INT_MAX || n < 0 || endp == s || *endp != 'x')
+ goto error;
+ config.posx = n;
+ s = endp+1;
+ n = strtol(s, &endp, 10);
+ if (errno == ERANGE || n > INT_MAX || n < 0 || endp == s)
+ goto error;
+ config.posy = n;
+ if (*endp == ':') {
+ s = endp+1;
+ mflag = 1;
+ if (strncasecmp(s, "CUR", 3) == 0) {
+ config.monitor = -1;
+ endp = s+3;
+ } else {
+ n = strtol(s, &endp, 10);
+ if (errno == ERANGE || n > INT_MAX || n < 0 || endp == s || *endp != '\0')
+ goto error;
+ config.monitor = n;
+ }
+ } else if (*endp != '\0') {
+ goto error;
+ }
+
+ return;
+
+error:
+ errx(1, "improper position: %s", optarg);
+}
+
+/* get configuration from X resources */
+static void
+getresources(void)
+{
+ char *type;
+ XrmValue xval;
+
+ if (xrm == NULL || xdb == NULL)
+ return;
+
+ if (XrmGetResource(xdb, "xmenu.borderWidth", "*", &type, &xval) == True)
+ GETNUM(config.border_pixels, xval.addr)
+ if (XrmGetResource(xdb, "xmenu.separatorWidth", "*", &type, &xval) == True)
+ GETNUM(config.separator_pixels, xval.addr)
+ if (XrmGetResource(xdb, "xmenu.height", "*", &type, &xval) == True)
+ GETNUM(config.height_pixels, xval.addr)
+ if (XrmGetResource(xdb, "xmenu.width", "*", &type, &xval) == True)
+ GETNUM(config.width_pixels, xval.addr)
+ if (XrmGetResource(xdb, "xmenu.gap", "*", &type, &xval) == True)
+ GETNUM(config.gap_pixels, xval.addr)
+ if (XrmGetResource(xdb, "xmenu.background", "*", &type, &xval) == True)
+ config.background_color = xval.addr;
+ if (XrmGetResource(xdb, "xmenu.foreground", "*", &type, &xval) == True)
+ config.foreground_color = xval.addr;
+ if (XrmGetResource(xdb, "xmenu.selbackground", "*", &type, &xval) == True)
+ config.selbackground_color = xval.addr;
+ if (XrmGetResource(xdb, "xmenu.selforeground", "*", &type, &xval) == True)
+ config.selforeground_color = xval.addr;
+ if (XrmGetResource(xdb, "xmenu.separator", "*", &type, &xval) == True)
+ config.separator_color = xval.addr;
+ if (XrmGetResource(xdb, "xmenu.border", "*", &type, &xval) == True)
+ config.border_color = xval.addr;
+ if (XrmGetResource(xdb, "xmenu.font", "*", &type, &xval) == True)
+ config.font = xval.addr;
+ if (XrmGetResource(xdb, "xmenu.alignment", "*", &type, &xval) == True) {
+ if (strcasecmp(xval.addr, "center") == 0)
+ config.alignment = CenterAlignment;
+ else if (strcasecmp(xval.addr, "left") == 0)
+ config.alignment = LeftAlignment;
+ else if (strcasecmp(xval.addr, "right") == 0)
+ config.alignment = RightAlignment;
+ }
+}
+
+/* get configuration from command-line options */
+static char *
+getoptions(int argc, char *argv[])