Skip to content

Commit

Permalink
add new user setting: Launch app on system login
Browse files Browse the repository at this point in the history
  • Loading branch information
aleksey-hoffman committed Jun 4, 2021
1 parent 09ef535 commit b018abc
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 4 deletions.
15 changes: 12 additions & 3 deletions src/electronMain.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,13 @@ function setAppProperties () {
// Temporary disable until native modules like 'node-diskusage'
// are updated (to become context-aware or loaded via N-API)
electron.app.allowRendererProcessReuse = false
// Handle system login
electron.app.setAppUserModelId('com.alekseyhoffman.sigma-file-manager')
}

function setCustomizedAppProperties (params) {
electron.app.setLoginItemSettings({
openAtLogin: true
openAtLogin: params.openAtLogin
})
electron.app.setAppUserModelId('com.alekseyhoffman.sigma-file-manager')
}

function createMainWindow () {
Expand Down Expand Up @@ -636,6 +638,12 @@ global.toggleApp = (options) => {
}
}

function getCustomizedAppProperties (storageData) {
return {
openAtLogin: storageData['storageData.settings.appProperties.openAtLogin'] || true
}
}

function initAppListeners () {
electron.app.on('render-process-gone', (event, webContents, details) => {
windows.main.loadURL('app://./index.html')
Expand Down Expand Up @@ -663,6 +671,7 @@ function initAppListeners () {
// initialization and is ready to create browser windows.
// Some APIs can only be used after this event occurs.
storageData = await fetchAppStorageData()
setCustomizedAppProperties(getCustomizedAppProperties(storageData))
disableAppMenu()
registerSafeFileProtocol()
createMainWindow()
Expand Down
3 changes: 3 additions & 0 deletions src/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,9 @@ export default new Vuex.Store({
},
settings: {
fileName: 'settings.json',
appProperties: {
openAtLogin: true
},
// TODO: Move to stats:
time: {
lastSearchScan: null
Expand Down
26 changes: 25 additions & 1 deletion src/views/Settings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,29 @@ Copyright © 2021 - present Aleksey Hoffman. All rights reserved.
</template>
</section-settings>

<!-- section::app properties -->
<section-settings
class="content-area__content-card__section"
:header="{
icon: {
name: 'mdi-tune',
},
title: 'App properties'
}"
>
<template v-slot:content>
<div class="text--sub-title-1 mt-2">
Startup behavior
</div>

<v-switch
v-model="appPropertiesOpenAtLogin"
label="Launch app on system login"
hide-details
></v-switch>
</template>
</section-settings>

<!-- section::window-controls -->
<section-settings
class="content-area__content-card__section"
Expand Down Expand Up @@ -1147,7 +1170,8 @@ export default {
selectedLanguage: 'storageData.settings.localization.selectedLanguage',
availableLanguages: 'storageData.settings.localization.availableLanguages',
spellcheck: 'storageData.settings.spellcheck',
globalSearchDisallowedPathsItems: 'storageData.settings.globalSearch.disallowedPathsItems'
globalSearchDisallowedPathsItems: 'storageData.settings.globalSearch.disallowedPathsItems',
appPropertiesOpenAtLogin: 'storageData.settings.appProperties.openAtLogin',
}
const objects = {}
for (const [modelKey, modelValue] of Object.entries(models)) {
Expand Down

0 comments on commit b018abc

Please sign in to comment.