https://github.com/hexedbits/StatusItemController
A "view controller" for menu bar Mac apps
https://github.com/hexedbits/StatusItemController
mac-app macos menubar menubar-app
Last synced: 4 months ago
JSON representation
A "view controller" for menu bar Mac apps
- Host: GitHub
- URL: https://github.com/hexedbits/StatusItemController
- Owner: hexedbits
- License: mit
- Created: 2020-03-31T19:22:38.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2024-02-14T20:20:18.000Z (about 1 year ago)
- Last Synced: 2024-09-18T02:45:08.258Z (5 months ago)
- Topics: mac-app, macos, menubar, menubar-app
- Language: Swift
- Homepage: https://hexedbits.github.io/StatusItemController/
- Size: 581 KB
- Stars: 67
- Watchers: 5
- Forks: 4
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# StatusItemController [](https://github.com/hexedbits/StatusItemController/actions)
*A "view controller" for menu bar Mac apps*
[](https://swiftpackageindex.com/hexedbits/StatusItemController)
[](https://swiftpackageindex.com/hexedbits/StatusItemController)## About
This library provides a `StatusItemController` component that you can use to create menu bar apps, or apps with menu bar items in macOS.
This component is used in [Red Eye](https://www.hexedbits.com/redeye/) and [Lucifer](https://www.hexedbits.com/lucifer/).
## Usage
1. Subclass `StatusItemController`
1. Implement the following methods:
1. `buildMenu() -> NSMenu`
1. `leftClickAction()`
1. `rightClickAction()`
1. Create an instance of your `StatusItemController` subclass in your `NSApplicationDelegate`.## Requirements
- macOS 11.0+
- Swift 5.9+
- Xcode 15.0+
- [SwiftLint](https://github.com/realm/SwiftLint)## Installation
### [CocoaPods](http://cocoapods.org)
````ruby
pod 'StatusItemController', '~> 2.0.0'
````### [Swift Package Manager](https://swift.org/package-manager/)
Add `StatusItemController` to the `dependencies` value of your `Package.swift`.
```swift
dependencies: [
.package(url: "https://github.com/hexedbits/StatusItemController", from: "2.0.0")
]
```Alternatively, you can add the package [directly via Xcode](https://developer.apple.com/documentation/xcode/adding_package_dependencies_to_your_app).
## Documentation
You can read the [documentation here](https://hexedbits.github.io/StatusItemController). Generated with [jazzy](https://github.com/realm/jazzy). Hosted by [GitHub Pages](https://pages.github.com).
## Notes on Testing
Unfortunately, `StatusItemController` cannot be tested directly. Attempting to create an `NSStatusItem` _outside_ of an app context throws an assert, which makes sense. Thus, in order to test `StatusItemController` it must be embedded in an app. Tests can be found in the Example App test suite. See [#15](https://github.com/hexedbits/StatusItemController/issues/15) for more details.
## Contributing
Interested in making contributions to this project? Please review the guides below.
- [Contributing Guidelines](https://github.com/hexedbits/.github/blob/main/CONTRIBUTING.md)
- [Code of Conduct](https://github.com/hexedbits/.github/blob/main/CODE_OF_CONDUCT.md)
- [Support and Help](https://github.com/hexedbits/.github/blob/main/SUPPORT.md)
- [Security Policy](https://github.com/hexedbits/.github/blob/main/SECURITY.md)Also consider [sponsoring this project](https://github.com/sponsors/jessesquires) or [buying my apps](https://www.hexedbits.com)! ✌️
## Credits
Created and maintained by [**Jesse Squires**](https://www.jessesquires.com).
## License
Released under the MIT License. See `LICENSE` for details.
> **Copyright © 2020-present Jesse Squires.**