-
-
Notifications
You must be signed in to change notification settings - Fork 444
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
331 additions
and
303 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1 @@ | ||
document.body.classList.add(process.platform) | ||
if (process.windowsStore) { | ||
document.body.classList.add('store') | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
const log = require('electron-log/main') | ||
|
||
class AutostartManager { | ||
constructor ({ | ||
platform, | ||
windowsStore, | ||
app | ||
}) { | ||
this.platform = platform | ||
this.windowsStore = windowsStore | ||
this.app = app | ||
} | ||
|
||
setAutostartEnabled (value) { | ||
if (this.platform === 'linux') { | ||
value ? this._linuxAutoLaunch.enable() : this._linuxAutoLaunch.disable() | ||
} else if (process.platform === 'win32' && process.windowsStore) { | ||
value ? this._windowsStoreAutoLaunch.enable() : this._windowsStoreAutoLaunch.disable() | ||
} else { | ||
this.app.setLoginItemSettings({ openAtLogin: value }) | ||
} | ||
log.info(`Stretchly: setting autostart to ${value} on ${this.platform}${this.platform === 'win32' && this.windowsStore ? ' (Windows Store)' : ''}`) | ||
} | ||
|
||
async autoLaunchStatus () { | ||
if (this.platform === 'linux') { | ||
return await this._linuxAutoLaunch.isEnabled() | ||
} else if (this.platform === 'win32' && this.windowsStore) { | ||
return await this._windowsStoreAutoLaunch.isEnabled() | ||
} else { | ||
return Promise.resolve(this.app.getLoginItemSettings().openAtLogin) | ||
} | ||
} | ||
|
||
get _linuxAutoLaunch () { | ||
const AutoLaunch = require('auto-launch') | ||
const stretchlyAutoLaunch = new AutoLaunch({ | ||
name: 'stretchly' | ||
}) | ||
return stretchlyAutoLaunch | ||
} | ||
|
||
get _windowsStoreAutoLaunch () { | ||
const AutoLaunch = require('auto-launch') | ||
const stretchlyAutoLaunch = new AutoLaunch({ | ||
name: 'Stretchly', | ||
path: '33881JanHovancik.stretchly_24fg4m0zq65je!Stretchly', | ||
isHidden: true | ||
}) | ||
return stretchlyAutoLaunch | ||
} | ||
} | ||
|
||
module.exports = AutostartManager |
Oops, something went wrong.