Skip to content

albertobeta/MenuBarOSXapp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Menu Bar app template for Mac OSX

This is a fully-working Xcode project to create a generic menu bar app (aka agent) located at the top right corner of the screen in Mac OS X.

enter image description here

The main components in this template are an AppDelegate and a .xib file containing the interface of the agent, which includes a contextual menu containing the "quit" option.

When compiled with Xcode, this project works out of the box. AppDelegate.swift contains a function called update() which can be fully customized to achieve the desired functionality of the agent (currently, it simply displays the time as a proof of concept). The function update() is triggered by the applicationDidFinishLaunching() method, where you can also specify the timeInterval in seconds between each call to the function:

Timer.scheduledTimer(timeInterval: 1, target: self, selector: #selector(AppDelegate.update), userInfo: nil, repeats: true)

Feel free to use this template to create your own menu bar agent. For instance, I built a simple app to bring back the battery time left in my macbook pro since the latest update of Mac OS X removed that feature and I was missing it.