Skip to content

Commit

Permalink
Show menu bar icon
Browse files Browse the repository at this point in the history
  • Loading branch information
hmarr committed Mar 21, 2021
1 parent 8e980cf commit a2c38cb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
6 changes: 4 additions & 2 deletions Vitals/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>LSUIElement</key>
<true/>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleExecutable</key>
Expand All @@ -22,8 +20,12 @@
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.utilities</string>
<key>LSMinimumSystemVersion</key>
<string>$(MACOSX_DEPLOYMENT_TARGET)</string>
<key>LSUIElement</key>
<true/>
<key>NSMainStoryboardFile</key>
<string>Main</string>
<key>NSPrincipalClass</key>
Expand Down
9 changes: 4 additions & 5 deletions Vitals/StatusBarController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ class StatusBarController {
self.contentViewModel = contentViewModel

statusBar = NSStatusBar.system
// Creating a status bar item having a fixed length
statusItem = statusBar.statusItem(withLength: 28.0)

let statusBarMenu = NSMenu(title: "Status Bar Menu")
Expand All @@ -33,7 +32,10 @@ class StatusBarController {
statusItem.menu = statusBarMenu

if let statusBarButton = statusItem.button {
statusBarButton.title = "📈"
statusBarButton.image = NSImage(named: "MenuIcon")
statusBarButton.image?.size = NSSize(width: 18.0, height: 18.0)
statusBarButton.image?.isTemplate = true


// This seems to work better than setting a target and action on the button - click events
// come through more quickly and reliably, and it doesn't seem to get stuck on double-clicks
Expand All @@ -54,9 +56,6 @@ class StatusBarController {
}
return event
}
// statusBarButton.image = #imageLiteral(resourceName: "StatusBarIcon")
// statusBarButton.image?.size = NSSize(width: 18.0, height: 18.0)
// statusBarButton.image?.isTemplate = true
}
}

Expand Down

0 comments on commit a2c38cb

Please sign in to comment.