[weston] weston-terminal: Add a few nice features
ahmet acar
oavc-fujie at yandex.com
Mon Sep 21 05:24:49 PDT 2015
Hi.This trivial patch adds 'cwd' (current working directory)
and 'command' (run specified command immediatelly after open)
features to weston-terminal.So this adds more use cases
and flexibility to our terminal.
Changes from:
commit 90e2d07ec1e6e46136e7b43f427a838f3e5b01ed
Author: Bryce Harrington <bryce at osg.samsung.com>
Date: Thu Sep 17 16:33:48 2015 -0700
---
clients/terminal.c | 30 +++++++++++++++++++++++++++---
1 file changed, 27 insertions(+), 3 deletions(-)
diff --git a/clients/terminal.c b/clients/terminal.c
index c5d5d60..f4e70e8 100644
--- a/clients/terminal.c
+++ b/clients/terminal.c
@@ -52,6 +52,8 @@ static char *option_font;
static int option_font_size;
static char *option_term;
static char *option_shell;
+static char *option_cwd;
+static char *option_command = "";
static struct wl_list terminal_list;
@@ -3046,6 +3048,19 @@ terminal_run(struct terminal *terminal, const char *path)
window_set_fullscreen(terminal->window, 1);
else
terminal_resize(terminal, 80, 24);
+
+ int cmdlen = strlen(option_command);
+
+ if(cmdlen)
+ {
+ char *newline = "\n";
+ strcat(option_command,newline);
+
+ if(write(master, option_command, cmdlen+1) == -1)
+ {
+ printf("An error occurred in %s at line %d\n", __FILE__, __LINE__);
+ }
+ }
return 0;
}
@@ -3055,6 +3070,9 @@ static const struct weston_option terminal_options[] = {
{ WESTON_OPTION_STRING, "font", 0, &option_font },
{ WESTON_OPTION_INTEGER, "font-size", 0, &option_font_size },
{ WESTON_OPTION_STRING, "shell", 0, &option_shell },
+ { WESTON_OPTION_STRING, "cwd", 0, &option_cwd },
+ { WESTON_OPTION_STRING, "command", 0, &option_command },
+
};
int main(int argc, char *argv[])
@@ -3087,7 +3105,9 @@ int main(int argc, char *argv[])
" --fullscreen or -f\n"
" --font=NAME\n"
" --font-size=SIZE\n"
- " --shell=NAME\n", argv[0]);
+ " --shell=NAME\n"
+ " --cwd=PATH\n"
+ " --command=CMDLINE\n", argv[0]);
return 1;
}
@@ -3099,10 +3119,14 @@ int main(int argc, char *argv[])
wl_list_init(&terminal_list);
terminal = terminal_create(d);
- if (terminal_run(terminal, option_shell))
- exit(EXIT_FAILURE);
+ if(chdir(option_cwd)){} //just for to suppress 'ignored return value' warning for happy gcc.
+
+ if (terminal_run(terminal, option_shell))
+ exit(EXIT_FAILURE);
+
display_run(d);
return 0;
}
More information about the wayland-devel
mailing list