Explorar o código

Construct a default path

Zachary Kotlarek %!s(int64=12) %!d(string=hai) anos
pai
achega
b655f5901b
Modificáronse 1 ficheiros con 8 adicións e 5 borrados
  1. 8 5
      speak/speak.m

+ 8 - 5
speak/speak.m

@@ -84,12 +84,15 @@ static void sockCallback (CFSocketRef sock, CFSocketCallBackType type, CFDataRef
 @end
 
 int main(int argc, const char *argv[]) {
-	if (argc < 2) {
-		return -1;
+
+	// Construct a default socket path or use the provided one
+	NSString *str;
+	if (argc > 1) {
+		str = [NSString stringWithUTF8String: argv[1]];
+	} else {
+		NSString *tmpDir = NSTemporaryDirectory();
+		str = [NSString stringWithFormat:@"%@plexMonitor/SPEAK.socket", tmpDir];
 	}
-		
-	// Convert from c-string to NSString
-	NSString *str = [NSString stringWithUTF8String: argv[1]];
 	
 	// Init the speech engine
 	synth = [[NSSpeechSynthesizer alloc] init];