Add support for login shells

This commit is contained in:
Pierre Pronchery 2016-03-28 18:26:21 +02:00
parent 7a43affb07
commit 9d70d80bc8
3 changed files with 23 additions and 3 deletions

View File

@ -70,6 +70,14 @@ static int _terminal(TerminalPrefs * prefs)
{
Terminal * terminal;
/* consistency check */
if(prefs != NULL)
{
if(prefs->shell != NULL)
prefs->login = 0;
else if(prefs->login != 0)
prefs->directory = NULL;
}
if((terminal = terminal_new(prefs)) == NULL)
return error_print(PACKAGE);
gtk_main();
@ -109,12 +117,15 @@ int main(int argc, char * argv[])
textdomain(PACKAGE);
memset(&prefs, 0, sizeof(prefs));
gtk_init(&argc, &argv);
while((o = getopt(argc, argv, "d:")) != -1)
while((o = getopt(argc, argv, "d:l")) != -1)
switch(o)
{
case 'd':
prefs.directory = optarg;
break;
case 'l':
prefs.login = 1;
break;
default:
return _usage();
}

View File

@ -72,6 +72,7 @@ struct _Terminal
{
char * shell;
char * directory;
unsigned int login;
/* internal */
TerminalTab * tabs;
@ -190,6 +191,7 @@ Terminal * terminal_new(TerminalPrefs * prefs)
? string_new(prefs->shell) : NULL;
terminal->directory = (prefs != NULL && prefs->directory != NULL)
? string_new(prefs->directory) : NULL;
terminal->login = (prefs != NULL) ? prefs->login : 0;
terminal->tabs = NULL;
terminal->tabs_cnt = 0;
terminal->window = NULL;
@ -273,7 +275,7 @@ static int _terminal_open_tab(Terminal * terminal)
TerminalTab * p;
GtkWidget * widget;
char * argv[] = { BINDIR "/xterm", "xterm", "-into", NULL,
"-class", "Terminal", NULL, NULL };
"-class", "Terminal", NULL, NULL, NULL };
char buf[32];
GSpawnFlags flags = G_SPAWN_FILE_AND_ARGV_ZERO
| G_SPAWN_DO_NOT_REAP_CHILD;
@ -311,7 +313,13 @@ static int _terminal_open_tab(Terminal * terminal)
snprintf(buf, sizeof(buf), "%lu", gtk_socket_get_id(
GTK_SOCKET(p->socket)));
argv[3] = buf;
argv[6] = terminal->shell;
if(terminal->login)
{
argv[6] = "-ls";
argv[7] = terminal->shell;
}
else
argv[6] = terminal->shell;
if(g_spawn_async(terminal->directory, argv, NULL, flags, NULL, NULL,
&p->pid, &error) == FALSE)
{

View File

@ -41,6 +41,7 @@ typedef struct _TerminalPrefs
{
char const * shell;
char const * directory;
unsigned int login;
} TerminalPrefs;
typedef struct _Terminal Terminal;