From 0b0700c4b7e67e4ee8c0a78093c48050598144de Mon Sep 17 00:00:00 2001 From: sabetts Date: Mon, 14 Apr 2003 00:42:58 +0000 Subject: (main): add switch case for the display command line option. (print_help): add --display option. Add text to demonstrate --display and --command take an argument. (ratpoison_longopts): add display. (ratpoison_longopts): add screen. (ratpoison_opts): add 'd' (ratpoison_opts): add 's' (main): parse the screen argument and process it. (print_help): add --screen --- src/main.c | 44 ++++++++++++++++++++++++++++++++++++++------ 1 file changed, 38 insertions(+), 6 deletions(-) (limited to 'src/main.c') diff --git a/src/main.c b/src/main.c index 627e315..d6b6eab 100644 --- a/src/main.c +++ b/src/main.c @@ -95,9 +95,10 @@ static struct option ratpoison_longopts[] = {"version", no_argument, 0, 'v'}, {"command", required_argument, 0, 'c'}, {"display", required_argument, 0, 'd'}, + {"screen", required_argument, 0, 's'}, {0, 0, 0, 0} }; -static char ratpoison_opts[] = "hvcd:"; +static char ratpoison_opts[] = "hvcd:s:"; void fatal (const char *msg) @@ -313,6 +314,7 @@ print_help () printf ("-h, --help Display this help screen\n"); printf ("-v, --version Display the version\n"); printf ("-d, --display Set the X display to use\n"); + printf ("-s, --screen Only use the specified screen\n"); printf ("-c, --command Send ratpoison a colon-command\n\n"); printf ("Report bugs to ratpoison-devel@lists.sourceforge.net\n\n"); @@ -500,6 +502,8 @@ main (int argc, char *argv[]) int c; char **command = NULL; int cmd_count = 0; + int screen_arg = 0; + int screen_num = 0; char *display = NULL; myargv = argv; @@ -537,6 +541,11 @@ main (int argc, char *argv[]) case 'd': display = xstrdup (optarg); break; + case 's': + screen_arg = 1; + screen_num = strtol (optarg, NULL, 10); + break; + default: exit (EXIT_FAILURE); } @@ -594,9 +603,24 @@ main (int argc, char *argv[]) screens = (screen_info *)xmalloc (sizeof (screen_info) * num_screens); PRINT_DEBUG (("%d screens.\n", num_screens)); - for (i=0; i= 0 && screen_num < num_screens) + { + init_screen (&screens[screen_num], screen_num); + } + else + { + fprintf (stderr, "%d is an invalid screen for the display\n", screen_num); + exit (EXIT_FAILURE); + } + } + else + { + for (i=0; i