From 7692d897cc69417326fd4f7c42c9f81cf326b3ad Mon Sep 17 00:00:00 2001 From: Carsten Haitzler Date: Wed, 22 Sep 1999 02:16:37 +0000 Subject: [PATCH] add -display option for eesh patch SVN revision: 360 --- eesh/E.h | 1 + eesh/globals.c | 1 + eesh/main.c | 77 ++++++++++++++++++++++++++++++-------------------- eesh/setup.c | 3 +- 4 files changed, 51 insertions(+), 31 deletions(-) diff --git a/eesh/E.h b/eesh/E.h index 31d0e9a5..7ac0f2d1 100644 --- a/eesh/E.h +++ b/eesh/E.h @@ -254,3 +254,4 @@ extern List lists; extern Window comms_win; extern Window my_win; extern Root root; +extern char *display_name; diff --git a/eesh/globals.c b/eesh/globals.c index f38e15bd..fc4cbfd1 100644 --- a/eesh/globals.c +++ b/eesh/globals.c @@ -5,3 +5,4 @@ List lists; Window comms_win; Window my_win; Root root; +char *display_name; diff --git a/eesh/main.c b/eesh/main.c index c0d4d8a2..1eb96487 100644 --- a/eesh/main.c +++ b/eesh/main.c @@ -14,9 +14,49 @@ main(int argc, char **argv) int i, j, k; fd_set fd; char ret; + char *command; waitonly = 0; lists.next = NULL; + display_name = NULL; + command = NULL; + + for (i = 0; i < argc; i++) + { + if (!strcmp(argv[i], "-e")) + { + if (i != (argc - 1)) + { + command = argv[++i]; + } + } + else if (!strcmp(argv[i], "-ewait")) + { + waitonly = 1; + if (i != (argc - 1)) + command = argv[++i]; + } + else if (!strcmp(argv[i], "-display")) + { + if (i != (argc - 1)) + display_name = duplicate(argv[++i]); + } + else if ((!strcmp(argv[i], "-h")) || + (!strcmp(argv[i], "--h")) || + (!strcmp(argv[i], "-help")) || + (!strcmp(argv[i], "--help"))) + { + printf("%s [ -e \"Command to Send to Enlightenment then exit\"]\n" + " [ -ewait \"Command to Send to E then wait for a reply then exit\"]\n", + argv[0]); + printf("Use \"%s\" by itself to enter the \"interactive mode\"\n" + "Ctrl-D will exit interactive mode (EOF)\n" + "use \"help\" from inside interactive mode for further " + "assistance\n", argv[0]); + exit(0); + } + } + SetupX(); CommsSetup(); CommsFindCommsWindow(); @@ -35,37 +75,14 @@ main(int argc, char **argv) CommsSend(e, "set info Enlightenment IPC Shell - talk to E direct"); /* CommsSend(e, "set pixmap 0"); */ - for (i = 0; i < argc; i++) + if (command) { - if (!strcmp(argv[i], "-e")) - { - if (i != (argc - 1)) - { - CommsSend(e, argv[++i]); - XSync(disp, False); - exit(0); - } - } - else if (!strcmp(argv[i], "-ewait")) - { - waitonly = 1; - if (i != (argc - 1)) - CommsSend(e, argv[++i]); - } - else if ((!strcmp(argv[i], "-h")) || - (!strcmp(argv[i], "--h")) || - (!strcmp(argv[i], "-help")) || - (!strcmp(argv[i], "--help"))) - { - printf("%s [ -e \"Command to Send to Enlightenment then exit\"]\n" - " [ -ewait \"Command to Send to E then wait for a reply then exit\"]\n", - argv[0]); - printf("Use \"%s\" by itself to enter the \"interactive mode\"\n" - "Ctrl-D will exit interactive mode (EOF)\n" - "use \"help\" from inside interactive mode for further " - "assistance\n", argv[0]); - exit(0); - } + CommsSend(e, command); + if (!waitonly) + { + XSync(disp, False); + exit(0); + } } XSync(disp, False); diff --git a/eesh/setup.c b/eesh/setup.c index b208e2e7..82b4a12e 100644 --- a/eesh/setup.c +++ b/eesh/setup.c @@ -5,7 +5,8 @@ SetupX() { EDBUG(6, "SetupX"); /* Open a connection to the diplay nominated by the DISPLAY variable */ - disp = XOpenDisplay(NULL); + /* Or set with the -display option */ + disp = XOpenDisplay(display_name); /* if cannot connect to display */ if (!disp) {