-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathTimeMachineRootListController.m
More file actions
40 lines (33 loc) · 1.79 KB
/
TimeMachineRootListController.m
File metadata and controls
40 lines (33 loc) · 1.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#import <Preferences/PSListController.h>
#import <Preferences/PSSpecifier.h>
#import "utils.h"
@interface TimeMachineRootListController : PSListController
@end
@implementation TimeMachineRootListController
- (NSArray *)specifiers {
if (!_specifiers) {
_specifiers = [self loadSpecifiersFromPlistName:@"Root" target:self];
}
return _specifiers;
}
- (void)setPreferenceValue:(id)value specifier:(PSSpecifier*)specifier {
[super setPreferenceValue:value specifier:specifier];
if ([[specifier propertyForKey:@"key"] isEqualToString:@"max_rootfs_snapshot"]) {
run_system([[NSString stringWithFormat:@"setTimeMachine -f / --n %@", value] UTF8String]);
} else if ([[specifier propertyForKey:@"key"] isEqualToString:@"max_datafs_snapshot"]) {
run_system([[NSString stringWithFormat:@"setTimeMachine -f /private/var --n %@", value] UTF8String]);
} else if ([[specifier propertyForKey:@"key"] isEqualToString:@"Hour"]) {
run_system([[NSString stringWithFormat:@"setTimeMachine -t --hour %@", value] UTF8String]);
} else if ([[specifier propertyForKey:@"key"] isEqualToString:@"Minute"]) {
run_system([[NSString stringWithFormat:@"setTimeMachine -t --minute %@", value] UTF8String]);
}
}
- (id)readPreferenceValue:(PSSpecifier*)specifier {
if ([[specifier propertyForKey:@"key"] isEqualToString:@"Hour"]) {
return [NSDictionary dictionaryWithContentsOfFile:@"/Library/LaunchDaemons/com.michael.TimeMachine.plist"][@"StartCalendarInterval"][@"Hour"];
} else if ([[specifier propertyForKey:@"key"] isEqualToString:@"Minute"]) {
return [NSDictionary dictionaryWithContentsOfFile:@"/Library/LaunchDaemons/com.michael.TimeMachine.plist"][@"StartCalendarInterval"][@"Minute"];
}
return [super readPreferenceValue:specifier];
}
@end