Skip to content

Commit

Permalink
Add option to hide icon (headless Bluesnooze)
Browse files Browse the repository at this point in the history
Request here:
#4
  • Loading branch information
odlp committed Feb 22, 2021
1 parent 6e03aad commit 439e0b3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
9 changes: 9 additions & 0 deletions Bluesnooze/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ class AppDelegate: NSObject, NSApplicationDelegate {
setLaunchAtLoginState()
}

@IBAction func hideIconClicked(_ sender: NSMenuItem) {
UserDefaults.standard.set(true, forKey: "hideIcon")
statusItem.statusBar?.removeStatusItem(statusItem)
}

@IBAction func quitClicked(_ sender: NSMenuItem) {
NSApplication.shared.terminate(self)
}
Expand Down Expand Up @@ -63,6 +68,10 @@ class AppDelegate: NSObject, NSApplicationDelegate {
// MARK: UI state

private func initStatusItem() {
if UserDefaults.standard.bool(forKey: "hideIcon") {
return
}

if let icon = NSImage(named: "bluesnooze") {
icon.isTemplate = true
statusItem.button?.image = icon
Expand Down
10 changes: 8 additions & 2 deletions Bluesnooze/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="15400" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="17701" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="15400"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="17701"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="NSApplication">
Expand All @@ -27,6 +27,12 @@
<action selector="launchAtLoginClicked:" target="Voe-Tx-rLC" id="ooK-DW-6Kn"/>
</connections>
</menuItem>
<menuItem title="Hide icon" id="iTh-xc-apd">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="hideIconClicked:" target="Voe-Tx-rLC" id="rZI-1a-Hhe"/>
</connections>
</menuItem>
<menuItem title="Quit" id="0IH-xa-Tvk">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
Expand Down

0 comments on commit 439e0b3

Please sign in to comment.