--- ./opt/wicd/daemon.py.sdg	2007-07-08 23:56:54.000000000 -0400
+++ ./opt/wicd/daemon.py	2007-09-16 18:30:30.000000000 -0400
@@ -51,8 +51,8 @@
 
 class FlushWriter:
 	def __init__(self):
-		print os.getcwd()
-		self.file = open('data/wicd.log','w')
+		if not PIDFile: print os.getcwd()
+		self.file = open('/var/log/wicd.log','w')
 		self.file.write(self.__getPrettyTime() + ' :: ')
 
 	def write(self,data):
@@ -122,8 +122,8 @@
 
 		DoAutoConnect = True
 
-		if len(sys.argv) > 1:
-			if sys.argv[1] == "--do-not-scan":
+		for opt in sys.argv[1:]:
+			if opt == "--do-not-scan":
 				print "--do-not-scan detected, not autoconnecting..."
 				DoAutoConnect = False
 
@@ -766,6 +766,11 @@
 ## fork from the parent terminal
 
 if True: #for easy disabling
+	for opt in sys.argv[1:]:
+		if opt.startswith('-P'):
+			PIDFile = opt[2:]
+			break
+        else:	PIDFile = None
 	try:
 		pid = os.fork()
 		if pid > 0:
@@ -783,7 +788,10 @@
 	try:
 		pid = os.fork()
 		if pid > 0:
-			print "wicd daemon: pid " + str(pid)
+			if PIDFile:
+				print >>open(PIDFile,'wt'),str(pid)
+			else:
+				print "wicd daemon: pid " + str(pid)
 			sys.exit(0)
 	except OSError, e:
 		print >>sys.stderr, "fork #2 failed: %d (%s)" % (e.errno, e.strerror)