Files
quark-shell-mac/README.md
Xhacker Liu bbe978ea22 Add license.
2014-07-26 22:17:59 -07:00

3.0 KiB
Raw Blame History

Menubar WebKit

menubar-webkit helps you create Mac menubar app using HTML and JavaScript without writing any Objective-C code. menubar-webkit exposes an JavaScript object called mw to provide system functions.

Screenshot

API

APIs may change rapidly before 1.0.

// Quit application
mw.quit()

// Open URL in default browser
mw.openURL("http://pomotodo.com")

// Set menubar icon
mw.setMenubarIcon("data:image/png;base64,iVBORw...SuQmCC")
mw.setMenubarHighlightedIcon("data:image/png;base64,iVBORw...SuQmCC")
mw.resetMenubarIcon()

// Auto start with system
mw.setAutoStart(true) // not implemented yet

// Send system notification
mw.notify({
  title: "Pomotodo",
  content: "Break is over!",
  popupOnClick: true // popup when clicking notification
})

// Set global keyboard shortcut
mw.addKeyboardShortcut({
  keycode: 0x7A, // F1 key
  modifierFlags: 0, // no modifier key
  callback: function suchCallback() {
    console.log("wow")
  }
})

// Clear global keyboard shortcut
mw.clearKeyboardShortcut()

// Setup preferences
// "label" is the toolbar item label in preferences window
// "identifier" is the preference html file name and must be unique
mw.setupPreferences([
  {"label": "General",  "identifier": "general",  "icon": "NSPreferencesGeneral"},
  {"label": "Account",  "identifier": "account",  "icon": "NSUserAccounts"},
  {"label": "Shortcut", "identifier": "shortcut", "icon": "NSAdvanced"}
])

// Open preferences
mw.openPreferences()

// Open new window
// "url" is relative to "public" folder
// Notice: You can only open one window at the same time,
// or the later window will replace the former window.
mw.newWindow({
  url: "about.html",
  width: 600,
  height: 400
}

// Close new window
mw.closeWindow()

// Pin/unpin pop-up window (wont close when click outside the window)
mw.pin()
mw.unpin()

Integrating Web App

public/index.html is the portal of your menubar app. public/preferences/[identifier].html are the preference pages (for example, public/preferences/general.html).

To add your own app:

rm public
git clone your.repository.address public

FAQ

  • Can I use local storage? Yes.
  • Can I use WebSQL? Yes.

Credits

Menubar WebKit was created by LIU Dongyuan (@xhacker) in the development of Pomotodo for Mac.

Some of the code are taken from:

Used third-party libraries:

Contribution

Pull requests are welcome! If you want to do something big, please open an issue first.

License

MIT