Skip to content

Commit 1c2bdbb

Browse files
committed
Fix important bug
Do not expect LaunchAgents to be present in /User/username/Library... We must create it
1 parent 032e5c2 commit 1c2bdbb

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

Manage Conky/ConkyPreferencesSheetController.m

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,12 +287,22 @@ - (IBAction)okButtonPressed:(id)sender
287287
/*
288288
* We must create and save the Conky Agent Property List File
289289
*/
290-
NSString *conkyAgentPlistPath = [NSString stringWithFormat:@"%@/Library/LaunchAgents/%@", NSHomeDirectory(), kConkyAgentPlistName];
290+
NSString *userLaunchAgentPath = [NSHomeDirectory() stringByAppendingString:@"/Library/LaunchAgents"];
291+
NSString *conkyAgentPlistPath = [NSString stringWithFormat:@"%@/%@", userLaunchAgentPath, kConkyAgentPlistName];
291292

292293
id objects[] = {kConkyLaunchAgentLabel, @[ kConkyExecutablePath, @"-b" ], [NSNumber numberWithBool:YES], [NSNumber numberWithBool:keepAlive], [NSNumber numberWithInteger:startupDelay_]};
293294
id keys[] = {@"Label", @"ProgramArguments", @"RunAtLoad", @"KeepAlive", @"ThrottleInterval"};
294295
NSUInteger count = sizeof(objects) / sizeof(id);
295296

297+
/* create LaunchAgents directory at User's Home */
298+
NSError *error;
299+
NSFileManager *fm = [NSFileManager defaultManager];
300+
[fm createDirectoryAtPath:userLaunchAgentPath withIntermediateDirectories:NO attributes:nil error:&error];
301+
if (error)
302+
{
303+
NSLog(@"Failed to create LaunchAgents directory @Home with error: \n\n%@", error);
304+
}
305+
296306
/* write the Agent plist */
297307
NSDictionary *conkyAgentPlist = [NSDictionary dictionaryWithObjects:objects forKeys:keys count:count];
298308
[conkyAgentPlist writeToFile:conkyAgentPlistPath atomically:YES];

0 commit comments

Comments
 (0)