Commits

John Floren  committed 306f8fa

program now takes the -d argument to select a display.

  • Participants
  • Parent commits 75b086a

Comments (0)

Files changed (2)

+*.o
+Tests/*.o
+*.swp
+anduin
+keyview
 #include <stdio.h>
 #include <string.h>
 #include <signal.h>
+#include <unistd.h>
 
 #include <sys/types.h>
 #include <sys/wait.h>
 	return -1;
 }
 
+void
+usage() {
+	printf("Usage: anduin <-d displayname> <conf file>");
+	exit(1);
+}
+
 //---------------------------------------------------------
 // Main 
 int main(int argc, char *argv[]) {
+	char c;
+	char *displayvar = "";
 	XEvent event;
 	int screen;
 	Window root;
 	int taskHeight, tickerHeight;
     XWindowChanges xwc;
 
-	if(argc > 1)
-		parseResources(resourceList, numResources, argv[1]);
+	while ((c = getopt(argc, argv, "d:")) != -1) {
+		switch(c) {
+		case 'd':
+			setenv("DISPLAY", optarg, 1);
+			break;
+		case '?':
+			usage();
+		}
+	}
+
+	if(optind < argc)
+		parseResources(resourceList, numResources, argv[optind]);
 	else 
 		parseResources(resourceList, numResources, NULL);
 
 	XInitThreads();
 
 	// Connect to the X server
-	display = XOpenDisplay("");
+	display = XOpenDisplay(NULL);
 	if(display == NULL) {
 		printf("Error opening display\n");
 		exit(1);