Skip to content

Instantly share code, notes, and snippets.

@gnachman
Created January 13, 2016 05:52
Show Gist options
  • Select an option

  • Save gnachman/d16ad74dfec628a9817b to your computer and use it in GitHub Desktop.

Select an option

Save gnachman/d16ad74dfec628a9817b to your computer and use it in GitHub Desktop.
diff --git a/sources/iTermProfilePreferences.m b/sources/iTermProfilePreferences.m
index 2561f5b..a74debb 100644
--- a/sources/iTermProfilePreferences.m
+++ b/sources/iTermProfilePreferences.m
@@ -12,6 +12,8 @@
#import "NSColor+iTerm.h"
#import "PreferencePanel.h"
+#define BLOCK(x) [[^id() { return [self x]; } copy] autorelease]
+
NSString *const kProfilePreferenceCommandTypeCustomValue = @"Yes";
NSString *const kProfilePreferenceCommandTypeLoginShellValue = @"No";
@@ -283,7 +285,7 @@ NSString *const kProfilePreferenceInitialDirectoryAdvancedValue = @"Advanced";
+ (NSDictionary *)computedObjectDictionary {
static NSDictionary *dict;
if (!dict) {
- dict = @{ };
+ dict = @{ KEY_IDLE_PERIOD: BLOCK(computedIdlePeriod) };
[dict retain];
}
return dict;
@@ -306,4 +308,9 @@ NSString *const kProfilePreferenceInitialDirectoryAdvancedValue = @"Advanced";
return object;
}
++ (NSNumber *)computedIdlePeriod {
+ static NSString *const kLegacyIdlePeriodKey = @"IdleTimeSeconds";
+ return [[NSUserDefaults standardUserDefaults] objectForKey:kLegacyIdlePeriodKey];
+}
+
@end
Copy link
Copy Markdown

ghost commented Jan 13, 2016

This resulted in:

  • The idleperiod setting was chopped down to one character, specifically the first character of whatever the value was previously in Idle Period. IE I had "20" stored in prefs, but the UI showed "2"
  • Run-time behavior was according to the chopped value. It sent codes every 2 seconds not 20.
  • But it did not re-save a "2" back into the prefs, even though I tried to enter the field to edit it.
  • You couldn't edit the value in the UI any more.
  • The "2" came from the new IdlePeriod field and not from the old AntiIdleTimerPeriod field, because I had "150" in that field.
Brians-MacBook-Air:~ bkw$ defaults read com.googlecode.iterm2 |grep Idle
    AntiIdleTimerPeriod = 150;
    IdleTimeSeconds = 2;
            "Idle Code" = 0;
            "Idle Period" = 20;
            "Send Code When Idle" = 1;
    NoSyncWarnAboutSendCodeWhenIdle = 1;
    "NoSyncWarnAboutSendCodeWhenIdle_selection" = 0;
Brians-MacBook-Air:~ bkw$ 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment