Skip to content

Commit

Permalink
0.2.0 Specify app tooltip via ANYBAR_TITLE (closes #59, closes #64)
Browse files Browse the repository at this point in the history
  • Loading branch information
tonsky committed Aug 26, 2020
1 parent 4ca8526 commit 2571377
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 66 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
xcuserdata
*.xcuserdatad
*.xcuserdata
build
*.zip
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,15 @@
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "C5AB32B71A8F9091002258B6"
BuildableName = "AnyBar.app"
BlueprintName = "AnyBar"
ReferencedContainer = "container:AnyBar.xcodeproj">
</BuildableReference>
</MacroExpansion>
<Testables>
<TestableReference
skipped = "NO">
Expand All @@ -53,17 +62,6 @@
</BuildableReference>
</TestableReference>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "C5AB32B71A8F9091002258B6"
BuildableName = "AnyBar.app"
BlueprintName = "AnyBar"
ReferencedContainer = "container:AnyBar.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Release"
Expand All @@ -85,8 +83,6 @@
ReferencedContainer = "container:AnyBar.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
Expand Down
39 changes: 11 additions & 28 deletions AnyBar/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ @interface AppDelegate()
@property (strong, nonatomic) NSString *imageName;
@property (assign, nonatomic) BOOL dark;
@property (assign, nonatomic) int udpPort;
@property (assign, nonatomic) NSString *appDesc;
@property (assign, nonatomic) NSString *appTitle;

@end

Expand All @@ -31,24 +31,23 @@ -(void)applicationDidFinishLaunching:(NSNotification *)aNotification {
@try {
_udpPort = [self getUdpPort];
_udpSocket = [self initializeUdpSocket: _udpPort];
_appDesc = [self getAppDesc];
_statusItem.toolTip = _appDesc;
_appTitle = [self readStringFromEnvironmentVariable:@"ANYBAR_TITLE" usingDefault:nil];
_statusItem.toolTip = _appTitle == nil ? [NSString stringWithFormat:@"AnyBar @ %d", _udpPort] : _appTitle;
}
@catch(NSException *ex) {
NSLog(@"Error: %@: %@", ex.name, ex.reason);
_statusItem.image = [NSImage imageNamed:@"exclamation@2x.png"];
}
@finally {
NSString *appTitle = _appDesc;
NSString *portTitle = [NSString stringWithFormat:@"UDP port: %@",
_udpPort >= 0 ? [NSNumber numberWithInt:_udpPort] : @"unavailable"];
NSString *quitTitle = @"Quit";
NSString *portTitle = [NSString stringWithFormat:@"UDP port: %@", _udpPort >= 0 ? [NSNumber numberWithInt:_udpPort] : @"unavailable"];
NSMenu *menu = [[NSMenu alloc] init];

_statusItem.menu = [self initializeStatusBarMenu:@{
portTitle: [NSValue valueWithPointer:nil],
quitTitle: [NSValue valueWithPointer:@selector(terminate:)],
appTitle: [NSValue valueWithPointer:nil]
}];
if (_appTitle != nil)
[menu addItemWithTitle:_appTitle action:nil keyEquivalent:@""];
[menu addItemWithTitle:portTitle action:nil keyEquivalent:@""];
[menu addItemWithTitle:@"Quit" action:@selector(terminate:) keyEquivalent:@""];

_statusItem.menu = menu;
}

NSDistributedNotificationCenter *center = [NSDistributedNotificationCenter defaultCenter];
Expand Down Expand Up @@ -79,10 +78,6 @@ -(int) getUdpPort {
return port;
}

-(NSString*) getAppDesc {
return [self readStringFromEnvironmentVariable:@"ANYBAR_DESC" usingDefault:@"AnyBar"];
}

- (void)refreshDarkMode {
NSString *osxMode = [[NSUserDefaults standardUserDefaults] stringForKey:@"AppleInterfaceStyle"];
if ([osxMode isEqualToString:@"Dark"])
Expand Down Expand Up @@ -187,18 +182,6 @@ -(NSStatusItem*) initializeStatusBarItem {
return statusItem;
}

-(NSMenu*) initializeStatusBarMenu:(NSDictionary*)menuDictionary {
NSMenu *menu = [[NSMenu alloc] init];

[menuDictionary enumerateKeysAndObjectsUsingBlock:^(NSString* key, NSValue* val, BOOL *stop) {
SEL action = nil;
[val getValue:&action];
[menu addItemWithTitle:key action:action keyEquivalent:@""];
}];

return menu;
}

-(int) readIntFromEnvironmentVariable:(NSString*) envVariable usingDefault:(NSString*) defStr {
int intVal = -1;

Expand Down
23 changes: 23 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
### 0.2.0 / Aug 26, 2020

- Specify app tooltip via `ANYBAR_TITLE` #59 #64 thx @mynameismiek @andrewsjg

### 0.1.4

- Bigger dots
- Render “black” on dark menubar as empty circle and “white” on dark as filled circle (#55)
- Compiled for OS X 10.11

### 0.1.3

- AppleScript support (PR #8, thx [Oleg Kertanov](https://github.com/okertanov))

### 0.1.2

- Dark mode support. In dark mode AnyBar will first check for `<image>_alt@2x.png` or `<image>_alt.png` image first, then falls back to `<image>.png`
- Support for Mavericks actually works

### 0.1.1

- Support for Mavericks (PR #2, thx [Oleg Kertanov](https://github.com/okertanov))
- Support for custom images via ~/.AnyBar (PR #1, thx [Paul Boschmann](https://github.com/pboschmann))
34 changes: 10 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ AnyBar is a small indicator for your menubar that does one simple thing: it disp

## Download

Version 0.1.4:
Version 0.2.0:

<a href="https://github.com/tonsky/AnyBar/releases/download/0.1.4/AnyBar-0.1.4.zip"><img src="AnyBar/Images.xcassets/AppIcon.appiconset/icon_128x128@2x.png?raw=true" style="width: 128px;" width=128/></a>
<a href="https://github.com/tonsky/AnyBar/releases/download/0.2.0/AnyBar-0.2.0.zip"><img src="AnyBar/Images.xcassets/AppIcon.appiconset/icon_128x128@2x.png?raw=true" style="width: 128px;" width=128/></a>

Or using [Homebrew Cask](https://github.com/Homebrew/homebrew-cask):

Expand Down Expand Up @@ -156,6 +156,14 @@ ANYBAR_PORT=1739 open -na AnyBar
ANYBAR_PORT=1740 open -na AnyBar
```

You can specify title to distinguish dots in the menubar:

```sh
ANYBAR_PORT=1738 ANYBAR_TITLE=First open -na AnyBar
ANYBAR_PORT=1739 ANYBAR_TITLE=Second open -na AnyBar
ANYBAR_PORT=1740 ANYBAR_TITLE=Third open -na AnyBar
```

## Custom images

AnyBar can detect and use local custom images stored in the `~/.AnyBar` directory. For example, if you have a `~/.AnyBar/square@2x.png` image, send `square` to port 1738 and it will be displayed. Images should be 19×19 pixels for standard resolution, and 38x38 pixels for retina (@2x).
Expand All @@ -167,28 +175,6 @@ AnyBar can detect and use local custom images stored in the `~/.AnyBar` director
- Windows 10 [PavelStefanov/NoteBar](https://github.com/PavelStefanov/NoteBar)
- Emacs [plexus/.../emybar.el](https://github.com/plexus/plexmacs/blob/master/emybar/emybar.el)

## Changelog

### 0.1.4

- Bigger dots
- Render “black” on dark menubar as empty circle and “white” on dark as filled circle (#55)
- Compiled for OS X 10.11

### 0.1.3

- AppleScript support (PR #8, thx [Oleg Kertanov](https://github.com/okertanov))

### 0.1.2

- Dark mode support. In dark mode AnyBar will first check for `<image>_alt@2x.png` or `<image>_alt.png` image first, then falls back to `<image>.png`
- Support for Mavericks actually works

### 0.1.1

- Support for Mavericks (PR #2, thx [Oleg Kertanov](https://github.com/okertanov))
- Support for custom images via ~/.AnyBar (PR #1, thx [Paul Boschmann](https://github.com/pboschmann))

## License

Copyright © 2015 Nikita Prokopov
Expand Down

0 comments on commit 2571377

Please sign in to comment.