Skip to content

Instantly share code, notes, and snippets.

@dcposch
Last active June 1, 2020 05:17
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save dcposch/1f07179a250d43ac667db897de3249fd to your computer and use it in GitHub Desktop.
Save dcposch/1f07179a250d43ac667db897de3249fd to your computer and use it in GitHub Desktop.
const win = new electron.BrowserWindow(...)
// When work makes progress, show the progress bar
function onProgress (progess) {
// Use values 0 to 1, or -1 to hide the progress bar
win.setProgressBar(progress || -1) // Progress bar works on all platforms
}
// When work completes while the app is in the background, show a badge
var numDoneInBackground = 0
function onDone () {
var dock = electron.app.dock // Badge works only on Mac
if (!dock || win.isFocused()) return
numDoneInBackground++
dock.setBadge('' + numDoneInBackground)
}
// Subscribe to the window focus event. When that happens, hide the badge
function onFocus () {
numDoneInBackground = 0
dock.setBadge('')
}
@DATADEER
Copy link

DATADEER commented Oct 11, 2017

spotted a tiny mistake in line 4 (progess -> progress)
btw awesome article :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment