diff options
Diffstat (limited to '')
-rw-r--r-- | terminal.vala | 16 | ||||
-rw-r--r-- | weltschmerz.1 | 11 |
2 files changed, 25 insertions, 2 deletions
diff --git a/terminal.vala b/terminal.vala index c6c2525..a7cfb6b 100644 --- a/terminal.vala +++ b/terminal.vala @@ -71,7 +71,7 @@ class Terminal : Gtk.Overlay { var argv = args[1:args.length]; if (argv.length == 0) { - argv = { Environment.get_variable("SHELL") }; + argv = { get_shell() }; } vte.spawn_sync(DEFAULT, null, argv, null, SEARCH_PATH, null, null, null); @@ -145,6 +145,20 @@ class Terminal : Gtk.Overlay { } } + string get_shell() { + var env_shell = Environment.get_variable("SHELL"); + if (env_shell != null && env_shell.length > 0){ + return env_shell; + } + + unowned Posix.Passwd pw = Posix.getpwuid(Posix.getuid()); + if (pw != null && pw.pw_shell.length > 0) { + return pw.pw_shell; + } + + return "/bin/sh"; + } + bool match_modifiers(int state, Gdk.ModifierType modifiers) { return (state & modifiers) == modifiers; } diff --git a/weltschmerz.1 b/weltschmerz.1 index bb834b5..eaf7f0c 100644 --- a/weltschmerz.1 +++ b/weltschmerz.1 @@ -18,8 +18,17 @@ reload its configuration whilst running. .Pp .Nm executes the given command, or the program specified in the -.Em SHELL +.Ev SHELL environment variable if no command was given. +If the +.Ev SHELL +environment variable is unset or empty, +.Nm +will fall back to the user's shell as configured in +.Pa /etc/passwd , +or finally use +.Pa /bin/sh +if there is no such entry. .Pp The clipboard can be copied to and pasted from with .Sy CTRL + Shift + C |