Skip to content

Instantly share code, notes, and snippets.

@DATADEER
Forked from dcposch/electron-dock.js
Created October 11, 2017 17:09
Show Gist options
  • Save DATADEER/5f7b253ca83171f9145fade293cd3fe3 to your computer and use it in GitHub Desktop.
Save DATADEER/5f7b253ca83171f9145fade293cd3fe3 to your computer and use it in GitHub Desktop.
const win = new electron.BrowserWindow(...)
// When work makes progress, show the progress bar
function onProgress (progress) {
// 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('')
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment