Skip to content

Commit

Permalink
testing Open at Login
Browse files Browse the repository at this point in the history
  • Loading branch information
lacymorrow committed Oct 16, 2019
1 parent 89b6efb commit 3e9f3bb
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 6 deletions.
15 changes: 9 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@ debug()
// Note: Must match `build.appId` in package.json
app.setAppUserModelId('com.lacymorrow.CrossOver')

app.setLoginItemSettings({
openAtLogin: true
})

// Uncomment this before publishing your first version.
// It's commented out as it throws an error if there are no published versions.
if (!is.development) {
Expand Down Expand Up @@ -165,6 +161,11 @@ const hideWindow = () => {
windowHidden = !windowHidden
}

const toggleWindowLock = () => {
const locked = config.get('windowLocked')
lockWindow(!locked)
}

// Allows dragging and setting options
const lockWindow = lock => {
console.log(`Locked: ${lock}`)
Expand Down Expand Up @@ -305,8 +306,10 @@ app.on('ready', () => {

// Toggle CrossOver
globalShortcut.register('Control+Shift+X', () => {
const locked = config.get('windowLocked')
lockWindow(!locked)
toggleWindowLock()
})
globalShortcut.register('CommandOrControl+,', () => {
toggleWindowLock()
})

// Hide CrossOver
Expand Down
22 changes: 22 additions & 0 deletions src/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,20 @@ const {
} = require('electron-util')
const config = require('./config')

const showBootLaunch = () => {
if (app.getLoginItemSettings().openAtLogin) {
console.log('Set open at login: true')
app.setLoginItemSettings({
openAtLogin: false
})
} else {
console.log('Set open at login: false')
app.setLoginItemSettings({
openAtLogin: true
})
}
}

const showPreferences = () => {
console.log('Show Preferences…')
}
Expand Down Expand Up @@ -126,6 +140,14 @@ const debugSubmenu = [

const macosTemplate = [
appMenu([
{
label: 'Open at startup',
type: 'checkbox',
checked: false,
click() {
showBootLaunch()
}
},
{
label: 'Preferences…',
accelerator: 'Command+,',
Expand Down

0 comments on commit 3e9f3bb

Please sign in to comment.