Skip to content

Commit

Permalink
Merge pull request #11 from ripienaar/1_3_0
Browse files Browse the repository at this point in the history
3rd party 1.3.0 release changes
  • Loading branch information
matryer committed Aug 19, 2015
2 parents 146003b + 8634eb4 commit f0a267d
Show file tree
Hide file tree
Showing 31 changed files with 59 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,31 +10,31 @@
<string>BitBar</string>
<key>IDESourceControlProjectOriginsDictionary</key>
<dict>
<key>58D5E363-3C19-4D83-91FE-1C8068E5C5E5</key>
<string>https://github.com/stretchr/bitbar-code.git</string>
<key>300A25E6089E8365F1B9BCC0BF644BF304850FDB</key>
<string>https://github.com/kamenevn/bitbar.git</string>
</dict>
<key>IDESourceControlProjectPath</key>
<string>BitBar/BitBar.xcodeproj/project.xcworkspace</string>
<string>App/BitBar.xcodeproj</string>
<key>IDESourceControlProjectRelativeInstallPathDictionary</key>
<dict>
<key>58D5E363-3C19-4D83-91FE-1C8068E5C5E5</key>
<key>300A25E6089E8365F1B9BCC0BF644BF304850FDB</key>
<string>../../..</string>
</dict>
<key>IDESourceControlProjectURL</key>
<string>https://github.com/stretchr/bitbar-code.git</string>
<string>https://github.com/kamenevn/bitbar.git</string>
<key>IDESourceControlProjectVersion</key>
<integer>110</integer>
<integer>111</integer>
<key>IDESourceControlProjectWCCIdentifier</key>
<string>58D5E363-3C19-4D83-91FE-1C8068E5C5E5</string>
<string>300A25E6089E8365F1B9BCC0BF644BF304850FDB</string>
<key>IDESourceControlProjectWCConfigurations</key>
<array>
<dict>
<key>IDESourceControlRepositoryExtensionIdentifierKey</key>
<string>public.vcs.git</string>
<key>IDESourceControlWCCIdentifierKey</key>
<string>58D5E363-3C19-4D83-91FE-1C8068E5C5E5</string>
<string>300A25E6089E8365F1B9BCC0BF644BF304850FDB</string>
<key>IDESourceControlWCCName</key>
<string>bitbar-code</string>
<string>bitbar</string>
</dict>
</array>
</dict>
Expand Down
13 changes: 1 addition & 12 deletions App/BitBar/ExecutablePlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -128,22 +128,11 @@ - (void) runPluginExternally {
}

- (void) addAdditionalMenuItems:(NSMenu *)menu {
NSMenuItem *copyItem = [[NSMenuItem alloc] initWithTitle:@"Copy" action:@selector(copyOutput) keyEquivalent:@"c"];
[copyItem setTarget:self];
[menu addItem:copyItem];

NSMenuItem *copyAllItems = [[NSMenuItem alloc] initWithTitle:@"Copy All" action:@selector(copyAllOutput) keyEquivalent:@"C"];
[copyAllItems setTarget:self];
[menu addItem:copyAllItems];


NSMenuItem *runItem = [[NSMenuItem alloc] initWithTitle:@"Run in Terminal…" action:@selector(runPluginExternally) keyEquivalent:@"o"];
[runItem setTarget:self];
[menu addItem:runItem];


// add the seperator
[menu addItem:[NSMenuItem separatorItem]];

}

@end
38 changes: 38 additions & 0 deletions App/BitBar/Plugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ - (NSMenuItem *) buildMenuItemWithParams:(NSDictionary *)params {
if ([params objectForKey:@"href"] != nil) {
sel = @selector(performMenuItemHREFAction:);
}
if ([params objectForKey:@"bash"] != nil) {
sel = @selector(performMenuItemOpenTerminalAction:);
}
NSMenuItem * item = [[NSMenuItem alloc] initWithTitle:title action:sel keyEquivalent:@""];
if (sel != nil) {
item.representedObject = params;
Expand Down Expand Up @@ -114,6 +117,41 @@ - (void) performMenuItemHREFAction:(NSMenuItem *)menuItem {
[[NSWorkspace sharedWorkspace] openURL:url];
}

- (void) performMenuItemOpenTerminalAction:(NSMenuItem *)menuItem {
NSMutableDictionary * params = menuItem.representedObject;
NSString *bash = [params objectForKey:@"bash"];
NSString *param1 = [params objectForKey:@"param1"];
NSString *param2 = [params objectForKey:@"param2"];
NSString *param3 = [params objectForKey:@"param3"];
NSString *terminal = [params objectForKey:@"terminal"];
if(param1 == nil) { param1 = @""; }
if(param2 == nil) { param2 = @""; }
if(param3 == nil) { param3 = @""; }
if(terminal == nil) {
terminal = [NSString stringWithFormat:@"%s", "true"];
}

//NSLog(@"%@", terminal);

if([terminal isEqual: @"false"]){
NSTask *task = [[NSTask alloc] init];
[task setLaunchPath:bash];
[task setArguments:@[ param1, param2, param3 ]];
[task launch];
}else{
NSString *full_link = [NSString stringWithFormat:@"%@ %@ %@ %@", bash, param1, param2, param3];
NSString *s = [NSString stringWithFormat:@"tell application \"Terminal\" \n\
activate \n\
if length of (get every window) is 0 then \n\
tell application \"System Events\" to tell process \"Terminal\" to click menu item \"New Window\" of menu \"File\" of menu bar 1 \n\
end if \n\
do script \"%@\" in front window activate \n\
end tell", full_link];
NSAppleScript *as = [[NSAppleScript alloc] initWithSource: s];
[as executeAndReturnError:nil];
}
}

- (void) rebuildMenuForStatusItem:(NSStatusItem*)statusItem {

// build the menu
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ Ensure the plugin is executable by running `chmod +x plugin.sh`.
* Your lines might contain `|` to separate the title from other parameters, such as...
* `href=..` to make the dropdown items clickable
* `color=..` to change their text color. eg. `color=red` or `color=#ff0000`
* `bash=..` to make the dropdown items open terminal with your script e.g. `bash=/Users/user/BitBar_Plugins/scripts/nginx.restart.sh`
* `param1=..` if sh script need params
* `param2=..` if sh script need params
* `param3=..` if sh script need params
* `terminal=..` if need to start bash script without open Terminal may be true or false
* If you're writing scripts, ensure it has a shebang at the top.

### Examples
Expand Down
Binary file removed Releases/BitBar-v1.2.app/Contents/MacOS/BitBar
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<plist version="1.0">
<dict>
<key>BuildMachineOSBuild</key>
<string>13B42</string>
<string>13F34</string>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
Expand All @@ -27,17 +27,17 @@
<key>DTCompiler</key>
<string>com.apple.compilers.llvm.clang.1_0</string>
<key>DTPlatformBuild</key>
<string>5A3005</string>
<string>6A2008a</string>
<key>DTPlatformVersion</key>
<string>GM</string>
<key>DTSDKBuild</key>
<string>13A595</string>
<string>14A382</string>
<key>DTSDKName</key>
<string>macosx10.9</string>
<string>macosx10.10</string>
<key>DTXcode</key>
<string>0502</string>
<string>0611</string>
<key>DTXcodeBuild</key>
<string>5A3005</string>
<string>6A2008a</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.productivity</string>
<key>LSMinimumSystemVersion</key>
Expand Down
Binary file added Releases/BitBar.app/Contents/MacOS/BitBar
Binary file not shown.
File renamed without changes.
Binary file not shown.

0 comments on commit f0a267d

Please sign in to comment.