diff options
author | sabetts <sabetts> | 2003-11-18 05:06:35 +0000 |
---|---|---|
committer | sabetts <sabetts> | 2003-11-18 05:06:35 +0000 |
commit | cf7ad617d4ce46c6bac6ac28e5323ab53e3ef17b (patch) | |
tree | 93a685a928d7ac7ae2960bf7441415f597ff6090 | |
parent | 5c658d8011fd459418a94e3524df0a72e08cd11b (diff) | |
download | ratpoison-cf7ad617d4ce46c6bac6ac28e5323ab53e3ef17b.zip |
* contrib/rpshowall.sh: store ratpoison binary location in
RATPOISON env var.
* src/ratpoison.h (FD_CLOEXEC): new define
(set_close_on_exec): new prototype
* src/main.c (ratpoison_longopts): add "interactive" option.
(ratpoison_opts): likewise
(print_help): print a help line for interactive option.
(set_close_on_exec): new function
(read_startup_files): call set_close_on_exec on file pointer
(main): parse interactive command line option and pass it to
send_command.
* src/events.c (execute_remote_command): pass the interactive bit
to command.
* src/communications.c (send_command): send an interactive bit at
the beginning of the message. Take an interactive argument. All
callers updated. Prototype updated.
* src/actions.c (cmd_source): call set_close_on_exec on file pointer.
-rw-r--r-- | AUTHORS | 1 | ||||
-rw-r--r-- | ChangeLog | 25 | ||||
-rw-r--r-- | contrib/rpshowall.sh | 24 | ||||
-rw-r--r-- | doc/ratpoison.texi | 4 | ||||
-rw-r--r-- | src/actions.c | 1 | ||||
-rw-r--r-- | src/communications.c | 11 | ||||
-rw-r--r-- | src/communications.h | 2 | ||||
-rw-r--r-- | src/events.c | 2 | ||||
-rw-r--r-- | src/main.c | 36 | ||||
-rw-r--r-- | src/ratpoison.h | 7 |
10 files changed, 88 insertions, 25 deletions
@@ -28,3 +28,4 @@ Rupert <rupert.debian@hotpop.com> Tim Goodwin <tjg@star.le.ac.uk> Joshua Neuheisel <jneuheisel@msn.com> Thien-Thi Nguyen <ttn@glug.org> +Joshua Neuheisel <jneuheisel@msn.com> @@ -1,3 +1,28 @@ +2003-11-17 Shawn Betts <sabetts@vcn.bc.ca> + + * contrib/rpshowall.sh: store ratpoison binary location in + RATPOISON env var. + + * src/ratpoison.h (FD_CLOEXEC): new define + (set_close_on_exec): new prototype + + * src/main.c (ratpoison_longopts): add "interactive" option. + (ratpoison_opts): likewise + (print_help): print a help line for interactive option. + (set_close_on_exec): new function + (read_startup_files): call set_close_on_exec on file pointer + (main): parse interactive command line option and pass it to + send_command. + + * src/events.c (execute_remote_command): pass the interactive bit + to command. + + * src/communications.c (send_command): send an interactive bit at + the beginning of the message. Take an interactive argument. All + callers updated. Prototype updated. + + * src/actions.c (cmd_source): call set_close_on_exec on file pointer. + 2003-11-16 Ryan Yeske <rcyeske@vcn.bc.ca> * contrib/rpshowall.sh: Added file. From Florian Cramer diff --git a/contrib/rpshowall.sh b/contrib/rpshowall.sh index 2465243..b4d8570 100644 --- a/contrib/rpshowall.sh +++ b/contrib/rpshowall.sh @@ -4,33 +4,35 @@ # ratpoison script to show all open windows # 2003 Florian Cramer <cantsin@zedat.fu-berlin.de> - +if [ -z $RATPOISON ]; then + RATPOISON=ratpoison +fi # Save current frameset -framecount=`ratpoison -c windows | wc -l | sed -e "s/[ ]*//g"` -curframe=`ratpoison -c windows | grep "^.\*" | sed -e "s/^\([0-9]*\)\*.*/\1/"` -ratpoison -c "setenv tmp `ratpoison -c 'fdump'`" +framecount=`$RATPOISON -c windows | wc -l | sed -e "s/[ ]*//g"` +curframe=`$RATPOISON -c windows | grep "^.\*" | sed -e "s/^\([0-9]*\)\*.*/\1/"` +$RATPOISON -c "setenv tmp `$RATPOISON -c 'fdump'`" # Create split view of all open windows -ratpoison -c only +$RATPOISON -c only i=2; while [ $i -le $framecount ]; do if [ $i -le `echo $framecount/2 | bc` ] ; then - ratpoison -c hsplit + $RATPOISON -c hsplit else - ratpoison -c vsplit + $RATPOISON -c vsplit fi - ratpoison -c focus - ratpoison -c focus + $RATPOISON -c focus + $RATPOISON -c focus i=$[$i+1]; done # Restore frameset -ratpoison -c "select $curframe" +$RATPOISON -c "select $curframe" echo -n "Restore window layout... " read i -ratpoison -c "frestore `ratpoison -c 'getenv tmp'`" +$RATPOISON -c "frestore `$RATPOISON -c 'getenv tmp'`" diff --git a/doc/ratpoison.texi b/doc/ratpoison.texi index 7d7eec4..6f22aff 100644 --- a/doc/ratpoison.texi +++ b/doc/ratpoison.texi @@ -1248,6 +1248,10 @@ $ ratpoison -c split -c split Here ratpoison would split the current frame twice. +@item -i, --interactive +Force ratpoison to execute commands in interactive mode. This is used +in conjuction with the @option{-c} option. + @end table @node Startup file, Command Index, Command Line Arguments, Top diff --git a/src/actions.c b/src/actions.c index 2b065e3..f547a38 100644 --- a/src/actions.c +++ b/src/actions.c @@ -736,6 +736,7 @@ cmd_source (int interactive, char *data) marked_message_printf (0, 0, " source: %s : %s ", data, strerror(errno)); else { + set_close_on_exec (fileptr); read_rc_file (fileptr); fclose (fileptr); } diff --git a/src/communications.c b/src/communications.c index 4e4e509..352a7ef 100644 --- a/src/communications.c +++ b/src/communications.c @@ -81,10 +81,15 @@ recieve_command_result (Window w) } int -send_command (unsigned char *cmd, int screen_num) +send_command (unsigned char interactive, unsigned char *cmd, int screen_num) { Window w; int done = 0; + struct sbuf *s; + + s = sbuf_new(0); + sbuf_printf(s, "%c%s", interactive, cmd); + /* If the user specified a specific screen, then send the event to that screen. */ @@ -103,12 +108,14 @@ send_command (unsigned char *cmd, int screen_num) XSelectInput (dpy, w, PropertyChangeMask); XChangeProperty (dpy, w, rp_command, XA_STRING, - 8, PropModeReplace, cmd, strlen (cmd) + 1); + 8, PropModeReplace, sbuf_get(s), strlen (cmd) + 2); XChangeProperty (dpy, DefaultRootWindow (dpy), rp_command_request, XA_WINDOW, 8, PropModeAppend, (unsigned char *)&w, sizeof (Window)); + sbuf_free (s); + while (!done) { XEvent ev; diff --git a/src/communications.h b/src/communications.h index 3bd6046..c371282 100644 --- a/src/communications.h +++ b/src/communications.h @@ -22,6 +22,6 @@ #ifndef _RATPOISON_COMMUNICATIONS_H #define _RATPOISON_COMMUNICATIONS_H 1 -int send_command (unsigned char *cmd, int screen_num); +int send_command (unsigned char interactive, unsigned char *cmd, int screen_num); #endif /* ! _RATPOISON_COMMUNICATIONS_H */ diff --git a/src/events.c b/src/events.c index 85548a4..7221883 100644 --- a/src/events.c +++ b/src/events.c @@ -446,7 +446,7 @@ execute_remote_command (Window w) } PRINT_DEBUG (("command: %s\n", req)); - result = command (0, req); + result = command (req[0], &req[1]); XFree (req); return result; @@ -48,14 +48,15 @@ static void init_screen (rp_screen *s, int screen_num); /* Command line options */ static struct option ratpoison_longopts[] = - { {"help", no_argument, 0, 'h'}, - {"version", no_argument, 0, 'v'}, - {"command", required_argument, 0, 'c'}, - {"display", required_argument, 0, 'd'}, - {"screen", required_argument, 0, 's'}, - {0, 0, 0, 0} }; + { {"help", no_argument, 0, 'h'}, + {"interactive", no_argument, 0, 'i'}, + {"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[] = "hvc:d:s:"; +static char ratpoison_opts[] = "hvic:d:s:"; void fatal (const char *msg) @@ -289,7 +290,8 @@ print_help () printf ("-v, --version Display the version\n"); printf ("-d, --display <dpy> Set the X display to use\n"); printf ("-s, --screen <num> Only use the specified screen\n"); - printf ("-c, --command <cmd> Send ratpoison a colon-command\n\n"); + printf ("-c, --command <cmd> Send ratpoison a colon-command\n"); + printf ("-i, --interactive Execute commands in interactive mode\n\n"); printf ("Report bugs to ratpoison-devel@lists.sourceforge.net\n\n"); @@ -297,6 +299,15 @@ print_help () } void +set_close_on_exec (FILE *fd) +{ + int fnum = fileno (fd); + int flags = fcntl (fnum, F_GETFD); + if (flags >= 0) + fcntl (fnum, F_SETFD, flags | FD_CLOEXEC); +} + +void read_rc_file (FILE *file) { size_t n = 256; @@ -384,6 +395,7 @@ read_startup_files () if (fileptr) { + set_close_on_exec(fileptr); read_rc_file (fileptr); fclose (fileptr); } @@ -484,6 +496,7 @@ main (int argc, char *argv[]) int screen_arg = 0; int screen_num = 0; char *display = NULL; + unsigned char interactive = 0; myargv = argv; @@ -524,6 +537,9 @@ main (int argc, char *argv[]) screen_arg = 1; screen_num = strtol (optarg, NULL, 10); break; + case 'i': + interactive = 1; + break; default: exit (EXIT_FAILURE); @@ -549,9 +565,9 @@ main (int argc, char *argv[]) for (i=0; i<cmd_count; i++) { if (screen_arg) - send_command (command[i], screen_num); + send_command (interactive, command[i], screen_num); else - send_command (command[i], -1); + send_command (interactive, command[i], -1); free (command[i]); } diff --git a/src/ratpoison.h b/src/ratpoison.h index 5d4bd7b..0a9719e 100644 --- a/src/ratpoison.h +++ b/src/ratpoison.h @@ -30,6 +30,12 @@ #include <stdio.h> #include <stdarg.h> #include <X11/Xlib.h> +#include <fcntl.h> + +/* Some systems don't define the close-on-exec flag in fcntl.h */ +#ifndef FD_CLOEXEC +# define FD_CLOEXEC 1 +#endif /* Helper macro for error and debug reporting. */ #define PRINT_LINE(type) printf (PACKAGE ":%s:%d: %s: ",__FILE__, __LINE__, #type) @@ -82,6 +88,7 @@ extern XGCValues gv; void clean_up (); rp_screen *find_screen (Window w); +void set_close_on_exec (FILE *fd); void read_rc_file (FILE *file); void fatal (const char *msg); |