1
0
mirror of https://github.com/bitwarden/desktop.git synced 2024-11-28 12:35:40 +01:00

Merge pull request #614 from Hinton/hotfix/autostart-snap

Fix autostart in snap
This commit is contained in:
Chad Scharf 2020-12-16 16:08:05 -05:00 committed by GitHub
commit 28c0fdd3f5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 46 additions and 8 deletions

2
jslib

@ -1 +1 @@
Subproject commit 2c414ce27a5c14f6cd7f86cfd07096a192d058ca
Subproject commit d7b5f0a26b15472b37aef2248dea51a2aa6d4916

View File

@ -221,6 +221,7 @@
"artifactName": "${productName}-${version}-${arch}.${ext}"
},
"snap": {
"autoStart": true,
"confinement": "strict",
"plugs": [
"default",

View File

@ -53,6 +53,7 @@ export class SettingsComponent implements OnInit {
alwaysShowDock: boolean;
showAlwaysShowDock: boolean = false;
openAtLogin: boolean;
requireEnableTray: boolean = false;
enableTrayText: string;
enableTrayDescText: string;
@ -70,6 +71,9 @@ export class SettingsComponent implements OnInit {
private userService: UserService, private cryptoService: CryptoService) {
const isMac = this.platformUtilsService.getDevice() === DeviceType.MacOsDesktop;
// Workaround to avoid ghosting trays https://github.com/electron/electron/issues/17622
this.requireEnableTray = this.platformUtilsService.getDevice() === DeviceType.LinuxDesktop;
const trayKey = isMac ? 'enableMenuBar' : 'enableTray';
this.enableTrayText = this.i18nService.t(trayKey);
this.enableTrayDescText = this.i18nService.t(trayKey + 'Desc');
@ -269,17 +273,44 @@ export class SettingsComponent implements OnInit {
}
async saveCloseToTray() {
if (this.requireEnableTray) {
this.enableTray = true;
await this.storageService.save(ElectronConstants.enableTrayKey, this.enableTray);
}
await this.storageService.save(ElectronConstants.enableCloseToTrayKey, this.enableCloseToTray);
this.callAnalytics('CloseToTray', this.enableCloseToTray);
}
async saveTray() {
if (this.requireEnableTray && !this.enableTray && (this.startToTray || this.enableCloseToTray)) {
const confirm = await this.platformUtilsService.showDialog(
this.i18nService.t('confirmTrayDesc'), this.i18nService.t('confirmTrayTitle'),
this.i18nService.t('yes'), this.i18nService.t('no'), 'warning');
if (confirm) {
this.startToTray = false;
await this.storageService.save(ElectronConstants.enableStartToTrayKey, this.startToTray);
this.enableCloseToTray = false;
await this.storageService.save(ElectronConstants.enableCloseToTrayKey, this.enableCloseToTray);
} else {
this.enableTray = true;
}
return;
}
await this.storageService.save(ElectronConstants.enableTrayKey, this.enableTray);
this.callAnalytics('Tray', this.enableTray);
this.messagingService.send(this.enableTray ? 'showTray' : 'removeTray');
}
async saveStartToTray() {
if (this.requireEnableTray) {
this.enableTray = true;
await this.storageService.save(ElectronConstants.enableTrayKey, this.enableTray);
}
await this.storageService.save(ElectronConstants.enableStartToTrayKey, this.startToTray);
this.callAnalytics('StartToTray', this.startToTray);
}

View File

@ -900,6 +900,12 @@
"alwaysShowDockDesc": {
"message": "Show the Bitwarden icon in the Dock even when minimized to the menu bar."
},
"confirmTrayTitle": {
"message": "Confirm disable tray"
},
"confirmTrayDesc": {
"message": "Disabling this setting will also disable all other tray related settings."
},
"language": {
"message": "Language"
},

View File

@ -102,13 +102,13 @@ export class MessagingMain {
private addOpenAtLogin() {
if (process.platform === 'linux') {
const data = `[Desktop Entry]
Type=Application
Version=${app.getVersion()}
Name=Bitwarden
Comment=Bitwarden startup script
Exec=${app.getPath('exe')}
StartupNotify=false
Terminal=false`;
Type=Application
Version=${app.getVersion()}
Name=Bitwarden
Comment=Bitwarden startup script
Exec=${app.getPath('exe')}
StartupNotify=false
Terminal=false`;
const dir = path.dirname(this.linuxStartupFile());
if (!fs.existsSync(dir)) {