forked from soapdog/menubar
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit a5eda0a
Showing
12 changed files
with
173 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.DS_Store | ||
node_modules |
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<html> | ||
<head> | ||
<title>Example App</title> | ||
</head> | ||
<body> | ||
hello world | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
var menubar = require('menubar') | ||
|
||
// doesnt use CLI args until https://github.com/atom/atom-shell/issues/1248 is resolved | ||
|
||
var args = { | ||
dir: __dirname | ||
} | ||
|
||
menubar(args, function ready (app) { | ||
console.log('ready', app) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"name": "example-menubar-app", | ||
"version": "1.0.0", | ||
"description": "example menubar atom-shell app", | ||
"dependencies": { | ||
"menubar": "1.0.0", | ||
"atom-shell": "0.22.1" | ||
}, | ||
"devDependencies": { | ||
"atom-shell-packager": "^1.1.0" | ||
}, | ||
"main": "main.js", | ||
"scripts": { | ||
"build": "atom-shell-packager . Example --ignore=node_modules/atom-shell --icon=Icon.icns", | ||
"start": "atom-shell ." | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# example menubar app | ||
|
||
## instructions | ||
|
||
- run `npm install` | ||
- run `npm run build` to make Example.app | ||
- run `npm start` to run app from CLI without building Example.app |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
var path = require('path') | ||
|
||
var app = require('app') | ||
var Tray = require('tray') | ||
var BrowserWindow = require('browser-window') | ||
var ipc = require('ipc') | ||
var shell = require('shell') | ||
|
||
var extend = require('extend') | ||
|
||
// atom shell has weird crash issues if you let certain atom-shell values get GC'd | ||
var win, icon | ||
|
||
module.exports = function create (opts, ready) { | ||
if (typeof opts === 'string') opts = {dir: opts} | ||
if (!(path.isAbsolute(opts.dir))) opts.dir = path.resolve(opts.dir) | ||
if (!opts.index) opts.index = path.join(opts.dir, 'index.html') | ||
|
||
app.on('ready', appReady) | ||
|
||
return app | ||
|
||
function appReady () { | ||
app.dock.hide() | ||
var atomScreen = require('screen') | ||
var size = atomScreen.getPrimaryDisplay() | ||
|
||
var canQuit = false | ||
app.on('will-quit', function tryQuit (e) { | ||
if (canQuit) return true | ||
win = undefined | ||
e.preventDefault() | ||
}) | ||
|
||
var iconPath = opts.icon || path.join(opts.dir, 'Icon.png') | ||
icon = new Tray(iconPath) | ||
|
||
icon.on('clicked', function clicked (e) { | ||
if (win && win.isVisible()) return hideWindow() | ||
showWindow() | ||
}) | ||
|
||
ready(null, app) | ||
|
||
function showWindow () { | ||
if (win) { | ||
return win.show() | ||
} | ||
var defaults = { | ||
width: 400, | ||
height: 400, | ||
show: true, | ||
frame: false | ||
} | ||
var winOpts = extend(defaults, winOpts) | ||
win = new BrowserWindow(defaults) | ||
var x = opts.x || size.workArea.width - 600 | ||
var y = opts.y || size.workArea.y | ||
win.setPosition(x, y) | ||
win.on('blur', hideWindow) | ||
win.loadUrl('file://' + opts.index) | ||
} | ||
|
||
function hideWindow () { | ||
if (win) return win.hide() | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{ | ||
"name": "menubar", | ||
"version": "1.0.0", | ||
"description": "high level way to create menubar desktop applications with atom-shell", | ||
"main": "index.js", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/maxogden/menubar.git" | ||
}, | ||
"keywords": [ | ||
"atom", | ||
"atom", | ||
"shell", | ||
"menubar", | ||
"menu", | ||
"mac", | ||
"app" | ||
], | ||
"author": "max ogden", | ||
"license": "BSD", | ||
"bugs": { | ||
"url": "https://github.com/maxogden/menubar/issues" | ||
}, | ||
"homepage": "https://github.com/maxogden/menubar", | ||
"dependencies": { | ||
"extend": "^2.0.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# menubar | ||
|
||
high level way to create menubar desktop applications with atom-shell | ||
|
||
this module provides boilerplate for setting up a menubar application using atom-shell. all you have to do is point it at your `index.html` and menubar icon and this will handle opening/closing a window when you click/blur. | ||
|
||
![screenshot](screenshot.png) | ||
|
||
## installation | ||
|
||
``` | ||
npm install menubar --save | ||
``` | ||
|
||
## usage | ||
|
||
create a JS program like this: | ||
|
||
```js | ||
var menubar = require('menubar') | ||
|
||
menubar({dir: __dirname}, function ready (app) { | ||
console.log('ready', app) | ||
}) | ||
``` | ||
|
||
make sure there is also a `index.html` file in `dir` | ||
|
||
then use [`atom-shell`](https://npmjs.org/atom-shell) or [`atom-shell-packager`](https://npmjs.org/atom-shell-packager) to build/run the app | ||
|
||
see `example/` for a working example |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.