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 ~

This commit is contained in:
Chris Jones 2010-04-18 09:49:32 +01:00
parent 6426236bed
commit 682f0bd3f7
2 changed files with 9 additions and 1 deletions

View File

@ -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)

View File

@ -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: