Skip to content

Commit

Permalink
Merge pull request #4 from pixel-point/fix-status-bar-icons
Browse files Browse the repository at this point in the history
New Tray Icons
  • Loading branch information
lnikell authored Jun 29, 2017
2 parents 4ea04f4 + a65891d commit 661663f
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 7 deletions.
49 changes: 44 additions & 5 deletions Mute Me Now/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,16 @@ @implementation AppDelegate

TouchButton *button;

NSString *STATUS_ICON_BLACK = @"tray-unactive-black";
NSString *STATUS_ICON_RED = @"tray-active";
NSString *STATUS_ICON_WHITE = @"tray-unactive-white";


- (void) awakeFromNib {


self.statusBar = [[NSStatusBar systemStatusBar] statusItemWithLength:NSVariableStatusItemLength];

NSImage* statusImage = [NSImage imageNamed:@"statusBarIcon"];
NSImage* statusImage = [self getStatusBarImage];

statusImage.size = NSMakeSize(18, 18);

Expand Down Expand Up @@ -59,8 +63,6 @@ - (void) awakeFromNib {

- (void) shortCutKeyPressed {

NSLog (@"shortcut key pressed");

[self updateMenuItem];

}
Expand Down Expand Up @@ -97,12 +99,49 @@ - (void)applicationDidFinishLaunching:(NSNotification *)aNotification {


[self enableLoginAutostart];

// fires if we enter / exit dark mode
[[NSDistributedNotificationCenter defaultCenter] addObserver:self selector:@selector(darkModeChanged:) name:@"AppleInterfaceThemeChangedNotification" object:nil];




}

-(void)darkModeChanged:(NSNotification *)notif
{
double volume = [self currentStateFixed];
[self setStatusBarImgRed: !volume];
}


- (NSImage*) getStatusBarImage {

NSImage* statusImage = [NSImage imageNamed:STATUS_ICON_BLACK];

// see https://stackoverflow.com/questions/25379525/how-to-detect-dark-mode-in-yosemite-to-change-the-status-bar-menu-icon
NSDictionary *dict = [[NSUserDefaults standardUserDefaults] persistentDomainForName:NSGlobalDomain];
id style = [dict objectForKey:@"AppleInterfaceStyle"];

BOOL darkModeOn = ( style && [style isKindOfClass:[NSString class]] && NSOrderedSame == [style caseInsensitiveCompare:@"dark"] );

if (darkModeOn) {
statusImage = [NSImage imageNamed:STATUS_ICON_WHITE];
}

return statusImage;
}


- (void) setStatusBarImgRed:(BOOL) shouldBeRed {

NSImage* statusImage = [NSImage imageNamed:@"statusBarIcon"];
NSImage* statusImage = [self getStatusBarImage];

if (shouldBeRed) {
NSLog (@"using red");
statusImage = [NSImage imageNamed:STATUS_ICON_RED];
}

statusImage.size = NSMakeSize(18, 18);
[statusImage setTemplate:!shouldBeRed];

Expand Down
2 changes: 0 additions & 2 deletions Mute Me Now/ViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ - (void)viewDidLoad {
BOOL statusBarState = [[NSUserDefaults standardUserDefaults] boolForKey:@"status_bar"];
[self.showInMenuBarState setState: statusBarState];



// enable to nil out preferences
//[[NSUserDefaults standardUserDefaults] setObject:nil forKey:@"status_bar"];
//[[NSUserDefaults standardUserDefaults] setObject:nil forKey:@"auto_login"];
Expand Down
20 changes: 20 additions & 0 deletions Mute Me.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
11B86E6B1EDE9D1A0069D254 /* volume_sript.scpt in Resources */ = {isa = PBXBuildFile; fileRef = 11B86E691EDE9D1A0069D254 /* volume_sript.scpt */; };
11B86E981EDEC6720069D254 /* ServiceManagement.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 11B86E921EDEAD1D0069D254 /* ServiceManagement.framework */; };
11EA56D81EF3C2AC003AF236 /* Mute Me Now Launcher.app in CopyFiles */ = {isa = PBXBuildFile; fileRef = 11C515681EEA9F6E004CE22A /* Mute Me Now Launcher.app */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
5D4763221F0562E6005E8DB0 /* [email protected] in Resources */ = {isa = PBXBuildFile; fileRef = 5D47631F1F0562E6005E8DB0 /* [email protected] */; };
5D4763231F0562E6005E8DB0 /* [email protected] in Resources */ = {isa = PBXBuildFile; fileRef = 5D4763201F0562E6005E8DB0 /* [email protected] */; };
5D4763241F0562E6005E8DB0 /* [email protected] in Resources */ = {isa = PBXBuildFile; fileRef = 5D4763211F0562E6005E8DB0 /* [email protected] */; };
5DA60BDA1EFAB9270045BDCF /* statusBarIcon2.png in Resources */ = {isa = PBXBuildFile; fileRef = 5DA60BD91EFAB9270045BDCF /* statusBarIcon2.png */; };
5DA60C531EFBC5400045BDCF /* statusBarIcon3.png in Resources */ = {isa = PBXBuildFile; fileRef = 5DA60C521EFBC5400045BDCF /* statusBarIcon3.png */; };
5DA60C551EFBC5D30045BDCF /* statusBarIcon.png in Resources */ = {isa = PBXBuildFile; fileRef = 5DA60C541EFBC5D30045BDCF /* statusBarIcon.png */; };
Expand Down Expand Up @@ -76,6 +79,9 @@
11B86E9A1EDECB3F0069D254 /* Mute Me Now.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = "Mute Me Now.entitlements"; sourceTree = "<group>"; };
30004556042F084BBC0CA872 /* libPods-Mute Me.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-Mute Me.a"; sourceTree = BUILT_PRODUCTS_DIR; };
51C19D181CC260D65112962D /* Pods-Mute Me.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Mute Me.release.xcconfig"; path = "Pods/Target Support Files/Pods-Mute Me/Pods-Mute Me.release.xcconfig"; sourceTree = "<group>"; };
5D47631F1F0562E6005E8DB0 /* [email protected] */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "[email protected]"; sourceTree = "<group>"; };
5D4763201F0562E6005E8DB0 /* [email protected] */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "[email protected]"; sourceTree = "<group>"; };
5D4763211F0562E6005E8DB0 /* [email protected] */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "[email protected]"; sourceTree = "<group>"; };
5DA60BD91EFAB9270045BDCF /* statusBarIcon2.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = statusBarIcon2.png; sourceTree = "<group>"; };
5DA60C521EFBC5400045BDCF /* statusBarIcon3.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = statusBarIcon3.png; sourceTree = "<group>"; };
5DA60C541EFBC5D30045BDCF /* statusBarIcon.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = statusBarIcon.png; sourceTree = "<group>"; };
Expand All @@ -99,6 +105,7 @@
11B86E441EDE9B4C0069D254 = {
isa = PBXGroup;
children = (
5D4763251F0562F2005E8DB0 /* Graphics */,
5DA60C541EFBC5D30045BDCF /* statusBarIcon.png */,
5DA60C521EFBC5400045BDCF /* statusBarIcon3.png */,
11B86E4F1EDE9B4D0069D254 /* Mute Me Now */,
Expand Down Expand Up @@ -166,6 +173,16 @@
name = Products;
sourceTree = "<group>";
};
5D4763251F0562F2005E8DB0 /* Graphics */ = {
isa = PBXGroup;
children = (
5D47631F1F0562E6005E8DB0 /* [email protected] */,
5D4763201F0562E6005E8DB0 /* [email protected] */,
5D4763211F0562E6005E8DB0 /* [email protected] */,
);
name = Graphics;
sourceTree = "<group>";
};
AB34A6744F649834F2A21B08 /* Pods */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -259,7 +276,10 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
5D4763241F0562E6005E8DB0 /* [email protected] in Resources */,
11B86E5A1EDE9B4D0069D254 /* Assets.xcassets in Resources */,
5D4763231F0562E6005E8DB0 /* [email protected] in Resources */,
5D4763221F0562E6005E8DB0 /* [email protected] in Resources */,
5DA60BDA1EFAB9270045BDCF /* statusBarIcon2.png in Resources */,
11B86E6A1EDE9D1A0069D254 /* mute_sript.scpt in Resources */,
5DA60C551EFBC5D30045BDCF /* statusBarIcon.png in Resources */,
Expand Down
Binary file added [email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added [email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added [email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 661663f

Please sign in to comment.