Fix linux not creating the autostart dir if not exist
This commit is contained in:
parent
75d26de581
commit
0cd196f56c
|
@ -17,7 +17,9 @@ export class MessagingMain {
|
||||||
|
|
||||||
init() {
|
init() {
|
||||||
this.scheduleNextSync();
|
this.scheduleNextSync();
|
||||||
if (process.platform !== 'linux') {
|
if (process.platform === 'linux') {
|
||||||
|
this.storageService.save(ElectronConstants.openAtLogin, fs.existsSync(this.linuxStartupFile()));
|
||||||
|
} else {
|
||||||
const loginSettings = app.getLoginItemSettings();
|
const loginSettings = app.getLoginItemSettings();
|
||||||
this.storageService.save(ElectronConstants.openAtLogin, loginSettings.openAtLogin);
|
this.storageService.save(ElectronConstants.openAtLogin, loginSettings.openAtLogin);
|
||||||
}
|
}
|
||||||
|
@ -98,6 +100,10 @@ export class MessagingMain {
|
||||||
StartupNotify=false
|
StartupNotify=false
|
||||||
Terminal=false`;
|
Terminal=false`;
|
||||||
|
|
||||||
|
const dir = path.dirname(this.linuxStartupFile());
|
||||||
|
if (!fs.existsSync(dir)) {
|
||||||
|
fs.mkdirSync(dir);
|
||||||
|
}
|
||||||
fs.writeFileSync(this.linuxStartupFile(), data);
|
fs.writeFileSync(this.linuxStartupFile(), data);
|
||||||
} else {
|
} else {
|
||||||
app.setLoginItemSettings({openAtLogin: true});
|
app.setLoginItemSettings({openAtLogin: true});
|
||||||
|
@ -106,9 +112,8 @@ export class MessagingMain {
|
||||||
|
|
||||||
private removeOpenAtLogin() {
|
private removeOpenAtLogin() {
|
||||||
if (process.platform === 'linux') {
|
if (process.platform === 'linux') {
|
||||||
const file = this.linuxStartupFile();
|
if (fs.existsSync(this.linuxStartupFile())) {
|
||||||
if (fs.existsSync(file)) {
|
fs.unlinkSync(this.linuxStartupFile());
|
||||||
fs.unlinkSync(file);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
app.setLoginItemSettings({openAtLogin: false});
|
app.setLoginItemSettings({openAtLogin: false});
|
||||||
|
|
Loading…
Reference in New Issue