From 682f0bd3f75676abe093c98e30eba1c83c7946b9 Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Sun, 18 Apr 2010 09:49:32 +0100 Subject: [PATCH] Apply some policy to the original cwd we inherit - if it's / then our parent process is probably some kind of app launcher, so we'll try to be helpful and make our cwd be ~ --- terminator | 2 +- terminatorlib/terminator.py | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/terminator b/terminator index 671a4e88..2c7f1918 100755 --- a/terminator +++ b/terminator @@ -52,7 +52,7 @@ if __name__ == '__main__': MAKER = Factory() TERMINATOR = Terminator() - TERMINATOR.origcwd = ORIGCWD + TERMINATOR.set_origcwd(ORIGCWD) TERMINATOR.reconfigure() try: TERMINATOR.create_layout(OPTIONS.layout) diff --git a/terminatorlib/terminator.py b/terminatorlib/terminator.py index 34726cba..e910026b 100755 --- a/terminatorlib/terminator.py +++ b/terminatorlib/terminator.py @@ -4,6 +4,7 @@ """terminator.py - class for the master Terminator singleton""" import copy +import os import gtk from borg import Borg @@ -63,6 +64,13 @@ class Terminator(Borg): if self.gnome_client is None: self.attempt_gnome_client() + def set_origcwd(self, cwd): + """Store the original cwd our process inherits""" + if cwd == '/': + cwd = os.path.expanduser('~') + os.chdir(cwd) + self.origcwd = cwd + def attempt_gnome_client(self): """Attempt to find a GNOME Session to register with""" try: