main.c: Add support to run user command inside the terminal
Add support for commandline options (--command or -e) using which one can provide commands to run inside the terminal as shown in below command :
$matchbox-terminal -e <command>
$matchbox-terminal --command <command>
Add standard command line options for gtk programs.
NOTE : The command line options -e and --command are chosen to mimic gnome-terminal and xterm which provide same options to run commands inside the terminals.
--- main.c | 37 +++++++++++++++++++++++++++++++------ 1 file changed, 31 insertions(+), 6 deletions(-)
main.c +31 -6
@@ -42,9 +42,32 @@ main (int argc, char **argv) {GtkWidget *window, *terminal, *scrolled_win;GError *err =NULL ; -char *cmd; +char *cmd =NULL ;char **cmd_argv =NULL ;int cmd_argc; +GOptionContext *context =NULL ; + +const GOptionEntry options[] = { + { +"command" ,'e' ,0 , +G_OPTION_ARG_STRING , &cmd, +"Execute a command in the terminal" ,NULL }, + {NULL } + }; + + context = +g_option_context_new + ("Open matchbox terminal and parser the command line args" ); +g_option_context_add_main_entries (context, options,NULL ); +g_option_context_add_group (context,gtk_get_option_group (TRUE)); +g_option_context_parse (context, &argc, &argv, &err); +g_option_context_free (context); + +if (err !=NULL ) { +g_printerr ("Failed to parse command line arguments: %s\n" , err->message); +g_error_free (err); +return -1 ; + }gtk_init (&argc, &argv);
@@ -67,11 +90,13 @@ main (int argc, char **argv) NULL);gtk_container_add (GTK_CONTAINER (scrolled_win), terminal); - cmd =vte_get_user_shell (); -if (!cmd) - cmd =g_strdup (g_getenv ("SHELL" )); -if (!cmd) - cmd =g_strdup ("/bin/sh" ); +if (cmd ==NULL ) { + cmd =vte_get_user_shell (); +if (!cmd) + cmd =g_strdup (g_getenv ("SHELL" )); +if (!cmd) + cmd =g_strdup ("/bin/sh" ); + }if (!g_shell_parse_argv (cmd, &cmd_argc, &cmd_argv, &err)) {g_printerr ("Failed to parse shell command line '%s'\n" , cmd);
--
2.7.4
This email and any attachments are intended for the sole use of the named recipient(s) and contain(s) confidential information that may be proprietary, privileged or copyrighted under applicable law. If you are not the intended recipient, do not read, copy, or forward this email message or any attachments. Delete this email message and any attachments immediately.
Quoted 6 lines · Devarsh Thakkar
Add support for commandline options (--command or -e) using which one can provide commands to run inside the terminal as shown in below command :
$matchbox-terminal -e <command> $matchbox-terminal --command <command>
Ross, who (if anyone) has write access to the mathcbox repo? I think matchbox stuff is in a bit of limbo currently?
Alex
Quoted 6 lines · Alexander Kanavin
Quoted 4 lines · Devarsh Thakkar
Add support for commandline options (--command or -e) using which one can provide commands to run inside the terminal as shown in below command :
Quoted 7 lines
Quoted 3 lines
$matchbox-terminal -e <command> $matchbox-terminal --command <command>Ross, who (if anyone) has write access to the mathcbox repo? I think matchbox stuff is in a bit of limbo currently?
I do, this was having a build test earlier so I'll be pushing shortly.
Ross
Hi Ross,
I would be glad if you could please share latest updates on this patch? If I am correct, last status was that a build test was triggered with this patch.
Thanks & Regards,
Devarsh
From: Burton, Ross [mailto:[email protected]]
Sent: Wednesday, March 14, 2018 12:33 PM
To: Alexander Kanavin <[email protected]>
Cc: Devarsh Thakkar <[email protected]>; Yocto-mailing-list <[email protected]>; Manjukumar Harthikote Matha <[email protected]>; vcu-team <[email protected]>; Devarsh Thakkar <[email protected]>
Subject: Re: [yocto] [matchbox-terminal] main.c: Add support to run user command inside the terminal
On 14 March 2018 at 18:44, Alexander Kanavin <[email protected]<mailto:[email protected]>> wrote:
On 03/14/2018 04:47 PM, Devarsh Thakkar wrote:
Add support for commandline options (--command or -e)
using which one can provide commands to run inside the terminal
as shown in below command :
$matchbox-terminal -e <command> $matchbox-terminal --command <command>
Ross, who (if anyone) has write access to the mathcbox repo? I think matchbox stuff is in a bit of limbo currently?
I do, this was having a build test earlier so I'll be pushing shortly.
Ross
Sorry, I failed to push. It's now been pushed to the matchbox-terminal repository.
Ross
Quoted 51 lines · Devarsh Thakkar
Hi Ross,
I would be glad if you could please share latest updates on this patch?
If I am correct, last status was that a build test was triggered with this patch.
Thanks & Regards,
Devarsh
From: Burton, Ross [mailto:[email protected]]
Sent: Wednesday, March 14, 2018 12:33 PM
To: Alexander Kanavin <[email protected]>
Cc: Devarsh Thakkar <[email protected]>; Yocto-mailing-list <[email protected]>; Manjukumar Harthikote Matha <[email protected]>; vcu-team <[email protected]>; Devarsh Thakkar <[email protected]>
Subject: Re: [yocto] [matchbox-terminal]main.c: Add support to run user command inside the terminalOn 14 March 2018 at 18:44, Alexander Kanavin
<[email protected]> wrote:On 03/14/2018 04:47 PM, Devarsh Thakkar wrote:
Add support for commandline options (--command or -e) using which one can provide commands to run inside the terminal as shown in below command :
$matchbox-terminal -e <command> $matchbox-terminal --command <command>Ross, who (if anyone) has write access to the mathcbox repo? I think matchbox stuff is in a bit of limbo currently?
I do, this was having a build test earlier so I'll be pushing shortly.
Ross