diff --git a/README.md b/README.md index 3d278aa..70f9880 100644 --- a/README.md +++ b/README.md @@ -4,12 +4,14 @@ noTunes is a macOS application that will prevent iTunes _or_ Apple Music from launching. -Simply launch the noTunes app and iTunes/Music will no longer be able to launch. For example, when bluetooth headphones reconnect to a laptop which may trigger iTunes/Music to open. +Simply launch the noTunes app and iTunes/Music will no longer be able to launch. For example, when bluetooth headphones reconnect. -You can enable/disable the apps functionality via the menu bar icon, which is a simple toggle. +You can toggle the apps functionality via the menu bar icon with a simple left click. ## Usage +### Toggle noTunes Funcationality + Left click the menu bar icon to toggle between its active states. **Enabled (prevents iTunes/Music from opening)** @@ -20,15 +22,29 @@ Left click the menu bar icon to toggle between its active states. ![noTunes Disabled](/screenshots/menubar-disabled.png) +### Hide Menu Bar Icon + +Right click the menu bar icon and click `Hide Icon`. + +### Restore Menu Bar Icon + +[Quit noTunes](#quit-notunes), run the following command in Terminal and re-open the app: + +```bash +defaults delete digital.twisted.noTunes +``` + +### Quit noTunes + To quit the app either: -**Menu bar version** +**With menu bar icon visible** Right click the menu bar icon and click quit. -**No menu bar version** +**With menu bar icon hidden** -Either quit the app via Activity Monitor or run the following command in Terminal: +Quit the app via Activity Monitor or run the following command in Terminal: ```bash osascript -e 'quit app "noTunes"' @@ -36,6 +52,8 @@ osascript -e 'quit app "noTunes"' ## Downloads -noTunes 3.0 (with menu bar icon): [noTunes-3.0.zip](https://github.com/tombonez/noTunes/releases/download/v3.0/noTunes-3.0.zip) +noTunes 3.1: [noTunes-3.1.zip](https://github.com/tombonez/noTunes/releases/download/v3.1/noTunes-3.1.zip) + +## License -noTunes 3.0 (without menu bar icon): [noTunes-3.0-noMenu.zip](https://github.com/tombonez/noTunes/releases/download/v3.0/noTunes-3.0-noMenu.zip) +The code is available under the [MIT License](https://github.com/tombonez/notunes/blob/master/LICENSE). diff --git a/noTunes.xcodeproj/project.pbxproj b/noTunes.xcodeproj/project.pbxproj index 81e838e..b823ba2 100644 --- a/noTunes.xcodeproj/project.pbxproj +++ b/noTunes.xcodeproj/project.pbxproj @@ -280,7 +280,7 @@ ENABLE_HARDENED_RUNTIME = YES; INFOPLIST_FILE = noTunes/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; - MARKETING_VERSION = 3.0; + MARKETING_VERSION = 3.1; PRODUCT_BUNDLE_IDENTIFIER = digital.twisted.noTunes; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_SWIFT3_OBJC_INFERENCE = Default; @@ -298,7 +298,7 @@ ENABLE_HARDENED_RUNTIME = YES; INFOPLIST_FILE = noTunes/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; - MARKETING_VERSION = 3.0; + MARKETING_VERSION = 3.1; PRODUCT_BUNDLE_IDENTIFIER = digital.twisted.noTunes; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_SWIFT3_OBJC_INFERENCE = Default; diff --git a/noTunes/AppDelegate.swift b/noTunes/AppDelegate.swift index e14bbb7..4e06d0d 100644 --- a/noTunes/AppDelegate.swift +++ b/noTunes/AppDelegate.swift @@ -11,11 +11,19 @@ import ServiceManagement @NSApplicationMain class AppDelegate: NSObject, NSApplicationDelegate { - - @IBOutlet weak var statusMenu: NSMenu! + + let defaults = UserDefaults.standard let statusItem = NSStatusBar.system.statusItem(withLength: NSStatusItem.variableLength) + @IBOutlet weak var statusMenu: NSMenu! + + @IBAction func hideIconClicked(_ sender: NSMenuItem) { + defaults.set(true, forKey: "hideIcon") + NSStatusBar.system.removeStatusItem(statusItem) + self.appIsLaunched() + } + @IBAction func quitClicked(_ sender: NSMenuItem) { NSApplication.shared.terminate(self) } @@ -45,6 +53,10 @@ class AppDelegate: NSObject, NSApplicationDelegate { button.sendAction(on: [.leftMouseUp, .rightMouseUp]) } + if defaults.bool(forKey: "hideIcon") { + NSStatusBar.system.removeStatusItem(statusItem) + } + self.appIsLaunched() self.createListener() } @@ -71,7 +83,7 @@ class AppDelegate: NSObject, NSApplicationDelegate { } @objc func appWillLaunch(note:Notification) { - if statusItem.image == NSImage(named: "StatusBarButtonImageActive") { + if statusItem.image == NSImage(named: "StatusBarButtonImageActive") || defaults.bool(forKey: "hideIcon") { if let processName:String = note.userInfo?["NSApplicationBundleIdentifier"] as? String { if let processId = note.userInfo?["NSApplicationProcessIdentifier"] as? Int { switch processName { diff --git a/noTunes/Base.lproj/MainMenu.xib b/noTunes/Base.lproj/MainMenu.xib index eff90b0..f6e832c 100644 --- a/noTunes/Base.lproj/MainMenu.xib +++ b/noTunes/Base.lproj/MainMenu.xib @@ -1,8 +1,8 @@ - + - + @@ -20,6 +20,13 @@ + + + + + + + @@ -27,6 +34,7 @@ +