Initial commit
This commit is contained in:
21
src/main/autostart.ts
Normal file
21
src/main/autostart.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import { app } from 'electron'
|
||||
|
||||
const HIDDEN_FLAG = '--hidden'
|
||||
|
||||
export function setAutostart(enabled: boolean): void {
|
||||
if (process.platform !== 'win32') return
|
||||
app.setLoginItemSettings({
|
||||
openAtLogin: enabled,
|
||||
path: process.execPath,
|
||||
args: [HIDDEN_FLAG]
|
||||
})
|
||||
}
|
||||
|
||||
export function isAutostartEnabled(): boolean {
|
||||
if (process.platform !== 'win32') return false
|
||||
return app.getLoginItemSettings().openAtLogin
|
||||
}
|
||||
|
||||
export function wasStartedHidden(): boolean {
|
||||
return process.argv.includes(HIDDEN_FLAG) || app.getLoginItemSettings().wasOpenedAsHidden
|
||||
}
|
||||
Reference in New Issue
Block a user