Skip to content

Commit

Permalink
Added Hide Icon Support
Browse files Browse the repository at this point in the history
  • Loading branch information
tombonez committed Sep 18, 2021
1 parent 0cd4627 commit b71e766
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 14 deletions.
32 changes: 25 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)**
Expand All @@ -20,22 +22,38 @@ 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"'
```

## 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).
4 changes: 2 additions & 2 deletions noTunes.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
18 changes: 15 additions & 3 deletions noTunes/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down Expand Up @@ -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()
}
Expand All @@ -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 {
Expand Down
12 changes: 10 additions & 2 deletions noTunes/Base.lproj/MainMenu.xib
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="14460.31" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="18122" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="14460.31"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="18122"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="NSApplication">
Expand All @@ -20,13 +20,21 @@
<customObject id="YLy-65-1bz" customClass="NSFontManager"/>
<menu id="WAR-Dm-F96">
<items>
<menuItem title="Hide Icon" id="BOM-2J-34i">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="hideIconClicked:" target="Voe-Tx-rLC" id="Oux-kD-7eE"/>
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="cqO-gs-dU5"/>
<menuItem title="Quit" id="tKr-kb-ZPz">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="quitClicked:" target="Voe-Tx-rLC" id="AAm-v2-v1x"/>
</connections>
</menuItem>
</items>
<point key="canvasLocation" x="32" y="88"/>
</menu>
<userDefaultsController representsSharedInstance="YES" id="4fn-wC-gIW"/>
</objects>
Expand Down

0 comments on commit b71e766

Please sign in to comment.