Skip to content

Commit

Permalink
1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
max-mapper committed Mar 23, 2015
0 parents commit a5eda0a
Show file tree
Hide file tree
Showing 12 changed files with 173 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.DS_Store
node_modules
Binary file added example/Icon.icns
Binary file not shown.
Binary file added example/Icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added example/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions example/index.html
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>
11 changes: 11 additions & 0 deletions example/main.js
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)
})
17 changes: 17 additions & 0 deletions example/package.json
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 ."
}
}
7 changes: 7 additions & 0 deletions example/readme.md
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
69 changes: 69 additions & 0 deletions index.js
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()
}
}
}

28 changes: 28 additions & 0 deletions package.json
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"
}
}
31 changes: 31 additions & 0 deletions readme.md
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
Binary file added screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit a5eda0a

Please sign in to comment.