Skip to content

Instantly share code, notes, and snippets.

@tudisco
Created June 6, 2017 12:53
Show Gist options
  • Save tudisco/ef68e59e0b1c87a5376eed79a65b958a to your computer and use it in GitHub Desktop.
Save tudisco/ef68e59e0b1c87a5376eed79a65b958a to your computer and use it in GitHub Desktop.
Electron Save Window Position
const {app, BrowserWindow} = require('electron')
const Config = require('electron-config')
const config = new Config()
let win
app.on('ready', () => {
let opts = {show: false}
Object.assign(opts, config.get('winBounds'))
win = new BrowserWindow(opts)
win.loadURL(`file://${__dirname}/app/index.html`)
win.once('ready-to-show', win.show)
// save window size and position
win.on('close', () => {
config.set('winBounds', win.getBounds())
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment