Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tetsuo/xtray
create minimal tray apps on osx
https://github.com/tetsuo/xtray
Last synced: about 2 months ago
JSON representation
create minimal tray apps on osx
- Host: GitHub
- URL: https://github.com/tetsuo/xtray
- Owner: tetsuo
- Created: 2015-07-24T22:40:26.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2015-08-03T22:42:23.000Z (over 9 years ago)
- Last Synced: 2024-10-31T08:39:28.947Z (2 months ago)
- Language: C++
- Homepage:
- Size: 129 KB
- Stars: 16
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
Awesome Lists containing this project
- awesome-desktop-js - xtray - create a native menubar app via a node.js ⇆ Swift bridge using objc runtime (macOS only) (System Tray / Flexbox)
README
# xtray
create minimal tray apps on osx.
![screenshot](http://i.imgur.com/gVCZMN7.png)
**Note: Swift 1.2 is no longer supported, so this module doesn't compile anymore. You can port the Swift part to Obj-C or look into the new Swift syntax if you really need to get this working.**
# example
```js
var xtray = require('xtray');xtray({
name: 'Demo',
icon: __dirname + '/icon.pdf'
}, function onlaunch () {
console.log('launched');
setInterval(function () {
console.log('loop is safe');
}, 1000);
}, function onquit () {
console.log('will quit');
});
```# api
```js
var xtray = require('xtray')
```## xtray(opts, [onlaunch, onquit])
Creates and launches the application.
`opts` object can have these properties:
- `icon` must be a pdf file, see [example/icon.pdf](example/icon.pdf) for an example
- `name` is the tooltip, the text which appears when you hover over the icon, and it is also appended to "Quit" textYou can provide the `onlaunch` callback that will be dispatched _after_ the application is finished launching. This doesn't block node.js i/o.
A `Quit [name]` menu item is added by default. There is no explicit terminate method; you can provide the `onquit` callback that will be dispatched _before_ the application quits.
# building
This is indeed a super minimal demonstration of building a simple node.js ⇆ Swift bridge using objc runtime. Requires a Xcode build (>=6.3-beta) which is capable of compiling Swift 1.2.
# packaging
Now, I haven't yet tested packaging a Swift framework, but it seems Xcode makes sure linked dependencies are also copied into `build` folder. I have tweaked search paths, so it should be safe to pack up `node_modules` as it is- greatly appreciated if you can open an issue if something goes wrong.
# license
mit