Permalink
Browse files

add default config

  • Loading branch information...
1 parent d15dbda commit ae501a525fd58235edbe42539159000a505655e7 Jigish Patel committed Jun 6, 2012
Showing with 70 additions and 11 deletions.
  1. +2 −0 README.md
  2. +4 −0 Slate.xcodeproj/project.pbxproj
  3. +2 −1 Slate/SlateConfig.h
  4. +14 −10 Slate/SlateConfig.m
  5. +48 −0 Slate/default.slate
View
@@ -32,6 +32,8 @@ build/Release/Slate.app is the packaged application. Throw it wherever you want
Slate is configured using a ".slate" file in the current user's home directory. Configuration is loaded upon running Slate. You can also re-load the config using the "Load Config" menu option on the status menu (use this at your own risk. It is better to simply restart Slate).
+**Note:** If no ".slate" file exists in the current user's home directory, the [default config file](https://github.com/jigish/slate/blob/master/Slate/default.slate) will be used.
+
Configuration is split into the following directives:
* `config` (for global configurations)
@@ -32,6 +32,7 @@
3BA7485913B1D0F500CFA792 /* MathUtils.m in Sources */ = {isa = PBXBuildFile; fileRef = 3BA7485813B1D0F500CFA792 /* MathUtils.m */; };
3BADA37213A2C1ED009E21D8 /* AccessibilityWrapper.m in Sources */ = {isa = PBXBuildFile; fileRef = 3BADA37113A2C1ED009E21D8 /* AccessibilityWrapper.m */; };
3BB5380413AEDA1B0005CFFC /* ScreenState.m in Sources */ = {isa = PBXBuildFile; fileRef = 3BB5380313AEDA190005CFFC /* ScreenState.m */; };
+ 3BBD24BA1580206C00940ABF /* default.slate in Resources */ = {isa = PBXBuildFile; fileRef = 3BBD24B91580206C00940ABF /* default.slate */; };
3BC9E96F15005925002FD1FA /* ActivateSnapshotOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = 3BC9E96E15005925002FD1FA /* ActivateSnapshotOperation.m */; };
3BC9E97315005F8F002FD1FA /* NSString+Levenshtein.m in Sources */ = {isa = PBXBuildFile; fileRef = 3BC9E97215005F8F002FD1FA /* NSString+Levenshtein.m */; };
3BCE40F513B15FF300804615 /* FocusOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = 3BCE40F413B15FF300804615 /* FocusOperation.m */; };
@@ -124,6 +125,7 @@
3BADA37113A2C1ED009E21D8 /* AccessibilityWrapper.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = AccessibilityWrapper.m; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objc; };
3BB5380213AEDA190005CFFC /* ScreenState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScreenState.h; sourceTree = "<group>"; };
3BB5380313AEDA190005CFFC /* ScreenState.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ScreenState.m; sourceTree = "<group>"; };
+ 3BBD24B91580206C00940ABF /* default.slate */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = default.slate; sourceTree = "<group>"; };
3BC9E96D15005925002FD1FA /* ActivateSnapshotOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ActivateSnapshotOperation.h; sourceTree = "<group>"; };
3BC9E96E15005925002FD1FA /* ActivateSnapshotOperation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ActivateSnapshotOperation.m; sourceTree = "<group>"; };
3BC9E97115005F8F002FD1FA /* NSString+Levenshtein.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSString+Levenshtein.h"; sourceTree = "<group>"; };
@@ -249,6 +251,7 @@
3BDDA18214FDAA6600829D2A /* SnapshotList.m */,
3BDDA17E14FDA55600829D2A /* WindowSnapshot.h */,
3BDDA17F14FDA55600829D2A /* WindowSnapshot.m */,
+ 3BBD24B91580206C00940ABF /* default.slate */,
);
name = Config;
sourceTree = "<group>";
@@ -491,6 +494,7 @@
4786D53513882381004554B1 /* ASCIIToCode.plist in Resources */,
47850891138BB234005DFB62 /* status.png in Resources */,
3B65CF251576CDF10063D298 /* ASCIIToCode_Dvorak.plist in Resources */,
+ 3BBD24BA1580206C00940ABF /* default.slate in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
View
@@ -42,7 +42,8 @@
+ (SlateConfig *)getInstance;
- (BOOL)load;
-- (BOOL)append:(NSString *)file;
+- (BOOL)loadConfigFileWithPath:(NSString *)file;
+- (BOOL)append:(NSString *)configString;
- (BOOL)loadSnapshots;
- (BOOL)getBoolConfig:(NSString *)key;
- (NSInteger)getIntegerConfig:(NSString *)key;
View
@@ -109,19 +109,19 @@ - (BOOL)load {
[self setDefaultLayouts:[[NSMutableArray alloc] init]];
[self setAliases:[[NSMutableDictionary alloc] init]];
- if (![self append:@"~/.slate"]) {
+ if (![self loadConfigFileWithPath:@"~/.slate"]) {
SlateLogger(@" ERROR Could not load ~/.slate");
NSAlert *alert = [[NSAlert alloc] init];
+ [alert addButtonWithTitle:@"Continue"];
[alert addButtonWithTitle:@"Quit"];
- [alert addButtonWithTitle:@"Skip"];
- [alert setMessageText:@"ERROR Could not load ~/.slate"];
- [alert setInformativeText:@"I dunno. Figure it out."];
+ [alert setMessageText:@"Could not load ~/.slate"];
+ [alert setInformativeText:@"The default configuration will be used. You can find the default .slate file at https://github.com/jigish/slate/blob/master/Slate/default.slate."];
[alert setAlertStyle:NSWarningAlertStyle];
- if ([alert runModal] == NSAlertFirstButtonReturn) {
+ if ([alert runModal] == NSAlertSecondButtonReturn) {
SlateLogger(@"User selected exit");
[NSApp terminate:nil];
}
- return NO;
+ return [self loadConfigFileWithPath:[[NSBundle mainBundle] pathForResource:@"default" ofType:@"slate"]];
}
if (![self loadSnapshots]) {
@@ -150,15 +150,19 @@ - (BOOL)load {
return YES;
}
-- (BOOL)append:(NSString *)file {
+- (BOOL)loadConfigFileWithPath:(NSString *)file {
if (file == nil) return NO;
NSString *configFile = file;
if ([file rangeOfString:SLASH].location != 0 && [file rangeOfString:TILDA].location != 0)
configFile = [NSString stringWithFormat:@"~/%@", file];
NSString *fileString = [NSString stringWithContentsOfFile:[configFile stringByExpandingTildeInPath] encoding:NSUTF8StringEncoding error:nil];
- if (fileString == nil)
+ return [self append:fileString];
+}
+
+- (BOOL)append:(NSString *)configString {
+ if (configString == nil)
return NO;
- NSArray *lines = [fileString componentsSeparatedByString:@"\n"];
+ NSArray *lines = [configString componentsSeparatedByString:@"\n"];
NSEnumerator *e = [lines objectEnumerator];
NSString *line = [e nextObject];
@@ -297,7 +301,7 @@ - (BOOL)append:(NSString *)file {
} else if ([tokens count] >= 2 && [[tokens objectAtIndex:0] isEqualToString:SOURCE]) {
// source filename optional:if_exists
SlateLogger(@" LoadingS: %@",line);
- if (![self append:[tokens objectAtIndex:1]]) {
+ if (![self loadConfigFileWithPath:[tokens objectAtIndex:1]]) {
if ([tokens count] >= 3 && [[tokens objectAtIndex:2] isEqualToString:IF_EXISTS]) {
SlateLogger(@" Could not find file '%@' but that's ok. User specified if_exists.",[tokens objectAtIndex:1]);
} else {
View
@@ -0,0 +1,48 @@
+# This is the default .slate file.
+# If no ~/.slate file exists this is the file that will be used.
+
+config defaultToCurrentScreen true
+config nudgePercentOf screenSize
+config resizePercentOf screenSize
+
+# Resize Bindings
+bind right:alt resize +10% +0
+bind left:alt resize -10% +0
+bind up:alt resize +0 -10%
+bind down:alt resize +0 +10%
+bind right:ctrl;alt resize -10% +0 bottom-right
+bind left:ctrl;alt resize +10% +0 bottom-right
+bind up:ctrl;alt resize +0 +10% bottom-right
+bind down:ctrl;alt resize +0 -10% bottom-right
+
+# Push Bindings
+bind right:ctrl;cmd push right bar-resize:screenSizeX/3
+bind left:ctrl;cmd push left bar-resize:screenSizeX/3
+bind up:ctrl;cmd push up bar-resize:screenSizeY/2
+bind down:ctrl;cmd push down bar-resize:screenSizeY/2
+
+# Nudge Bindings
+bind right:shift;alt nudge +10% +0
+bind left:shift;alt nudge -10% +0
+bind up:shift;alt nudge +0 -10%
+bind down:shift;alt nudge +0 +10%
+
+# Throw Bindings
+bind 1:ctrl;alt throw 0 resize
+bind 2:ctrl;alt throw 1 resize
+bind 3:ctrl;alt throw 2 resize
+bind right:ctrl;alt;cmd throw right resize
+bind left:ctrl;alt;cmd throw left resize
+bind up:ctrl;alt;cmd throw up resize
+bind down:ctrl;alt;cmd throw down resize
+
+# Focus Bindings
+bind right:cmd focus right
+bind left:cmd focus left
+bind up:cmd focus up
+bind down:cmd focus down
+bind up:cmd;alt focus behind
+bind down:cmd;alt focus behind
+
+# Window Hints
+bind esc:cmd hint

0 comments on commit ae501a5

Please sign in to comment.