Skip to content

Commit

Permalink
add: app: status item: initial code
Browse files Browse the repository at this point in the history
  • Loading branch information
monuk7735 committed Feb 27, 2025
1 parent 551b37f commit 9f8ce61
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 11 deletions.
6 changes: 4 additions & 2 deletions MewNotch.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@
ENABLE_HARDENED_RUNTIME = YES;
ENABLE_PREVIEWS = YES;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.utilities";
INFOPLIST_KEY_LSBackgroundOnly = YES;
INFOPLIST_KEY_NSHumanReadableCopyright = "";
INFOPLIST_KEY_UIUserInterfaceStyle = Dark;
Expand All @@ -274,7 +275,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 14.0;
MARKETING_VERSION = 1.0;
MARKETING_VERSION = 0.1;
PRODUCT_BUNDLE_IDENTIFIER = com.monuk7735.mew.notch;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = YES;
Expand All @@ -296,6 +297,7 @@
ENABLE_HARDENED_RUNTIME = YES;
ENABLE_PREVIEWS = YES;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.utilities";
INFOPLIST_KEY_LSBackgroundOnly = YES;
INFOPLIST_KEY_NSHumanReadableCopyright = "";
INFOPLIST_KEY_UIUserInterfaceStyle = Dark;
Expand All @@ -304,7 +306,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 14.0;
MARKETING_VERSION = 1.0;
MARKETING_VERSION = 0.1;
PRODUCT_BUNDLE_IDENTIFIER = com.monuk7735.mew.notch;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = YES;
Expand Down
25 changes: 16 additions & 9 deletions MewNotch/MewAppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import MediaKeyTap
class MewAppDelegate: NSObject, NSApplicationDelegate {

@Environment(\.openWindow) var openWindow
@Environment(\.openSettings) var openSettingsWindow

var windows: [NSScreen: NSWindow] = [:]

Expand Down Expand Up @@ -74,33 +75,39 @@ class MewAppDelegate: NSObject, NSApplicationDelegate {
}

func createStatusItem() {
let item = NSStatusBar.system.statusItem(withLength: NSStatusItem.squareLength)
let statusItem = NSStatusBar.system.statusItem(
withLength: NSStatusItem.squareLength
)

let menu = NSMenu()

menu.items = [
NSMenuItem(
title: "Quit App",
title: "Settings",
action: #selector(openSettings),
keyEquivalent: "S"
),
NSMenuItem(
title: "Quit",
action: #selector(quitApp),
keyEquivalent: "Q"
),
]

item.menu = menu
// statusItem.menu = menu

item.isVisible = true

if let button = item.button {
// button.image = NSImage(named: "muse")
button.image = NSStatusBarButton.init(checkboxWithTitle: "", target: nil, action: nil).image
if let button = statusItem.button {
button.image = NSImage(
named: "Speaker"
)
button.image?.isTemplate = true

button.identifier = NSUserInterfaceItemIdentifier("MewStatusItem")
}
}

@objc func openSettings() {

openSettingsWindow()
}

@objc func quitApp() {
Expand Down

0 comments on commit 9f8ce61

Please sign in to comment.