Skip to content

Instantly share code, notes, and snippets.

@Rolograaf
Forked from halida/close_to_tray.js.coffee
Created March 30, 2014 13:42
Show Gist options
  • Save Rolograaf/9872992 to your computer and use it in GitHub Desktop.
Save Rolograaf/9872992 to your computer and use it in GitHub Desktop.
mylib.close_to_tray = ->
gui = require('nw.gui')
win = gui.Window.get()
tray = null
win.on 'close', ->
this.hide()
tray = new gui.Tray({ icon: 'icon.jpg' })
tray.on 'click', ->
win.show()
this.remove()
tray = null
menu = new gui.Menu()
menu.append(new gui.MenuItem(type: 'normal', label: 'Quit', click: gui.App.quit))
tray.menu = menu
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment