support a login shell option.

SVN revision: 77141
This commit is contained in:
Carsten Haitzler 2012-09-27 09:33:33 +00:00
parent 8de26cadab
commit 57ef054525
5 changed files with 28 additions and 7 deletions

View File

@ -350,6 +350,8 @@ static const Ecore_Getopt options = {
ECORE_GETOPT_CHOICE ('v', "video-module",
"Set emotion module to use.", emotion_choices),
ECORE_GETOPT_STORE_BOOL('l', "login",
"Run the shell as a login shell."),
ECORE_GETOPT_STORE_BOOL('m', "video-mute",
"Set mute mode for video playback."),
ECORE_GETOPT_STORE_BOOL('c', "cursor-blink",
@ -393,6 +395,7 @@ elm_main(int argc, char **argv)
char *icon_name = NULL;
char *font = NULL;
char *video_module = NULL;
Eina_Bool login_shell = 0xff; /* unset */
Eina_Bool video_mute = 0xff; /* unset */
Eina_Bool cursor_blink = 0xff; /* unset */
Eina_Bool visual_bell = 0xff; /* unset */
@ -416,6 +419,7 @@ elm_main(int argc, char **argv)
ECORE_GETOPT_VALUE_STR(font),
ECORE_GETOPT_VALUE_STR(video_module),
ECORE_GETOPT_VALUE_BOOL(login_shell),
ECORE_GETOPT_VALUE_BOOL(video_mute),
ECORE_GETOPT_VALUE_BOOL(cursor_blink),
ECORE_GETOPT_VALUE_BOOL(visual_bell),
@ -622,11 +626,16 @@ elm_main(int argc, char **argv)
pos_set = 1;
}
}
// later allow default size to be configured
if (!size_set)
{
size_w = 80;
size_h = 24;
}
// for now if not set - dont do login shell - later from config
if (login_shell == 0xff) login_shell = EINA_FALSE;
// set an env so terminal apps can detect they are in terminology :)
putenv("TERMINOLOGY=1");
@ -698,7 +707,7 @@ elm_main(int argc, char **argv)
evas_object_event_callback_add(o, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _cb_cmd_hints_changed, bg);
edje_object_part_swallow(bg, "terminology.cmdbox", o);
term = o = termio_add(win, config, cmd, cd, size_w, size_h);
term = o = termio_add(win, config, cmd, login_shell, cd, size_w, size_h);
termio_win_set(o, win);
evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_fill_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL);

View File

@ -2246,7 +2246,7 @@ _smart_pty_command(void *data)
}
Evas_Object *
termio_add(Evas_Object *parent, Config *config, const char *cmd, const char *cd, int w, int h)
termio_add(Evas_Object *parent, Config *config, const char *cmd, Eina_Bool login_shell, const char *cd, int w, int h)
{
Evas *e;
Evas_Object *obj, *g;
@ -2285,7 +2285,7 @@ termio_add(Evas_Object *parent, Config *config, const char *cmd, const char *cd,
termpty_init();
sd->pty = termpty_new(cmd, cd, w, h, config->scrollback);
sd->pty = termpty_new(cmd, login_shell, cd, w, h, config->scrollback);
sd->pty->cb.change.func = _smart_pty_change;
sd->pty->cb.change.data = obj;
sd->pty->cb.scroll.func = _smart_pty_scroll;

View File

@ -3,7 +3,7 @@
#include "config.h"
Evas_Object *termio_add(Evas_Object *parent, Config *config, const char *cmd, const char *cd, int w, int h);
Evas_Object *termio_add(Evas_Object *parent, Config *config, const char *cmd, Eina_Bool login_shell, const char *cd, int w, int h);
void termio_win_set(Evas_Object *obj, Evas_Object *win);
char *termio_selection_get(Evas_Object *obj, int c1x, int c1y, int c2x, int c2y);
void termio_config_update(Evas_Object *obj);

View File

@ -233,7 +233,7 @@ _limit_coord(Termpty *ty, Termstate *state)
}
Termpty *
termpty_new(const char *cmd, const char *cd, int w, int h, int backscroll)
termpty_new(const char *cmd, Eina_Bool login_shell, const char *cd, int w, int h, int backscroll)
{
Termpty *ty;
const char *pty;
@ -337,7 +337,19 @@ termpty_new(const char *cmd, const char *cd, int w, int h, int backscroll)
putenv("TERM=xterm");
// putenv("TERM=xterm-256color");
putenv("XTERM_256_COLORS=1");
execvp(args[0], (char *const *)args);
if (!login_shell)
execvp(args[0], (char *const *)args);
else
{
char *cmdfile, *cmd0;
cmdfile = (char *)args[0];
cmd0 = alloca(strlen(cmdfile) + 2);
cmd0[0] = '-';
strcpy(cmd0 + 1, cmdfile);
args[0] = cmd0;
execvp(cmdfile, (char *const *)args);
}
exit(127); /* same as system() for failed commands */
}
ty->hand_fd = ecore_main_fd_handler_add(ty->fd, ECORE_FD_READ,

View File

@ -126,7 +126,7 @@ struct _Termsave
void termpty_init(void);
void termpty_shutdown(void);
Termpty *termpty_new(const char *cmd, const char *cd, int w, int h, int backscroll);
Termpty *termpty_new(const char *cmd, Eina_Bool login_shell, const char *cd, int w, int h, int backscroll);
void termpty_free(Termpty *ty);
Termcell *termpty_cellrow_get(Termpty *ty, int y, int *wret);
void termpty_write(Termpty *ty, const char *input, int len);