0.1.0 • Published 5 years ago

electron-tray-indicator v0.1.0

Weekly downloads
15
License
MIT
Repository
github
Last release
5 years ago

electron-tray-indicator

A progress indicator in tray for your Electron app.

Install

$ npm install electron-tray-indicator --save

Usage

Working with a determinate progress:

import { Tray } from 'electron'
import { progress, clean } from 'electron-tray-indicator'

function start(tray: Tray) {
  let p = 0

  const tick = () => {
    progress({
      tray: tray,
      progress: p,
    })

    p += 0.5
    if (p < 100) {
      setTimeout(tick, 16)
    } else {
      // update the tray with your `img`
      tray.setImage(img)
      // clean the background resources (a hidden window)
      clean()
    }
  }

  tick()
}

start()

Working with an indeterminate progress:

import { Tray } from 'electron'
import { indeterminate, clean } from 'electron-tray-indicator'

const stop = indeterminate({
  tray,
})

// just call `stop` when some task finished
stop()

// then update the tray with your `img`
tray.setImage(img)

// finally you can call `clean` to release the background resources
clean()

Examples

Find more examples see the ./examples.

Contributing

Pull requests and stars are highly welcome.

For bugs and feature requests, please create an issue.