Skip to content

Commit

Permalink
Showing 2 changed files with 9 additions and 7 deletions.
15 changes: 8 additions & 7 deletions App/BitBar/Plugin.m
Original file line number Diff line number Diff line change
@@ -62,22 +62,23 @@ - (NSMenuItem*) buildMenuItemWithParams:(NSDictionary *)params {
item.representedObject = params;
[item setTarget:self];
}
if ([params objectForKey:@"color"] != nil) {
if (params[@"size"] || params[@"color"])
item.attributedTitle = [self attributedTitleWithParams:params];
}

return item;
}

- (NSAttributedString*) attributedTitleWithParams:(NSDictionary *)params {
NSString * title = [params objectForKey:@"title"];
NSFont * font = [NSFont menuFontOfSize:14.0];

NSString * title = params[@"title"];
NSFont * font = [NSFont menuFontOfSize:params[@"size"] ? [params[@"size"] floatValue] : 14];
NSMutableAttributedString * attributedTitle = [NSMutableAttributedString.alloc initWithString:title attributes:@{NSFontAttributeName: font}];
if ([params objectForKey:@"color"] != nil) {
if (params[@"color"]) {
NSColor * fgColor = [NSColor colorWithWebColorString:[params objectForKey:@"color"]];
if (fgColor != nil) {
if (fgColor)
[attributedTitle addAttribute:NSForegroundColorAttributeName value:fgColor range:NSMakeRange(0, title.length)];
}
}

return attributedTitle;
}

1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -65,6 +65,7 @@ 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`
* `size=..` to change their text size. eg. `size=12`
* `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

0 comments on commit ad0e16d

Please sign in to comment.