+/* 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[])
+{
+ int ch;
+
+ while ((ch = getopt(argc, argv, "ip:rw")) != -1) {
+ switch (ch) {
+ case 'i':
+ iflag = 1;
+ break;
+ case 'p':
+ pflag = 1;
+ parseposition(optarg);
+ break;
+ case 'r':
+ rflag = 1;
+ break;
+ case 'w':
+ wflag = 1;
+ break;
+ default:
+ usage();
+ break;
+ }
+ }
+ argc -= optind;
+ argv += optind;
+ if (argc > 1)
+ usage();
+ else if (argc == 1)
+ return *argv;
+ return PROGNAME;
+}
+