From 23494269d7fb6bec696f305caa79a683ceb4bcbd Mon Sep 17 00:00:00 2001 From: sabetts Date: Mon, 19 Mar 2001 08:35:36 +0000 Subject: * src/main.c (ratpoison_longopts): add --command to recognized command-line options. * src/communications.h (send_command): new function prototype * src/data.h (rp_command): new global variable * src/events.c (receive_command): new function (property_notify): handles rp_command Atoms * src/communications.c (send_command): new function * src/main.c (print_help): prints help for --command (main): handles --command command-line option --- src/main.c | 34 +++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) (limited to 'src/main.c') diff --git a/src/main.c b/src/main.c index a7c9674..5cbf4c2 100644 --- a/src/main.c +++ b/src/main.c @@ -50,6 +50,7 @@ Atom wm_colormaps; Atom rp_restart; Atom rp_kill; +Atom rp_command; screen_info *screens; int num_screens; @@ -68,12 +69,15 @@ struct rp_key prefix_key; struct modifier_info rp_modifier_info; /* Command line options */ -static struct option ratpoison_longopts[] = { {"help", no_argument, 0, 'h'}, - {"version", no_argument, 0, 'v'}, - {"restart", no_argument, 0, 'r'}, - {"kill", no_argument, 0, 'k'}, - {0, 0, 0, 0} }; -static char ratpoison_opts[] = "hvrk"; +static struct option ratpoison_longopts[] = + { {"help", no_argument, 0, 'h'}, + {"version", no_argument, 0, 'v'}, + {"restart", no_argument, 0, 'r'}, + {"kill", no_argument, 0, 'k'}, + {"command", required_argument, 0, 'c'}, + {0, 0, 0, 0} }; + +static char ratpoison_opts[] = "hvrkc:"; void fatal (const char *msg) @@ -205,7 +209,8 @@ print_help () printf ("-h, --help Display this help screen\n"); printf ("-v, --version Display the version\n"); printf ("-r, --restart Restart ratpoison\n"); - printf ("-k, --kill Kill ratpoison\n\n"); + printf ("-k, --kill Kill ratpoison\n"); + printf ("-c, --command Send ratpoison a colon-command\n\n"); printf ("Report bugs to ratpoison-devel@lists.sourceforge.net\n\n"); @@ -306,6 +311,8 @@ main (int argc, char *argv[]) int c; int do_kill = 0; int do_restart = 0; + int do_command = 0; + char *command; myargv = argv; @@ -331,6 +338,11 @@ main (int argc, char *argv[]) case 'r': do_restart = 1; break; + case 'c': + command = xmalloc (strlen (optarg) + 1); + strcpy (command, optarg); + do_command = 1; + break; default: exit (EXIT_FAILURE); } @@ -352,6 +364,7 @@ main (int argc, char *argv[]) /* Set ratpoison specific Atoms. */ rp_restart = XInternAtom (dpy, "RP_RESTART", False); rp_kill = XInternAtom (dpy, "RP_KILL", False); + rp_command = XInternAtom (dpy, "RP_COMMAND", False); if (do_kill) { @@ -367,6 +380,13 @@ main (int argc, char *argv[]) clean_up (); return EXIT_SUCCESS; } + if (do_command) + { + send_command (command); + free (command); + clean_up(); + return EXIT_SUCCESS; + } /* Set our Atoms */ wm_state = XInternAtom(dpy, "WM_STATE", False); -- cgit v1.2.3