My Electron app has two modes, let's call them A and B.*
When switching between the two modes, I'm creating a new BrowserWindow and changing the dock icon (see "What I've Tried" below).
Is there a way to make it so that when a user right-clicks > "Keep in Dock" on MacOS in Mode A it creates a distinct docked app icon that launches the app into mode A, and vice versa for mode B?
I.e. is it possible to have multiple docked icons for a single Electron app?
*: The modes A and B essentially boots the same React app, where A is a stripped-down version of the app. Some users prefer to only use the stripped down version, which is why I want to enable docking separate versions of the app. And I don't want to bundle A as a separate app since the user needs to be able to switch between the two modes inside the app's UI.
What I've tried
let windowA;
let windowB;
const bootInModeA = () => {
windowA = new BrowserWindow({
...,
icon: 'iconA.png',
})
// Change dock icon.
const realmImage = nativeImage.createFromPath(getAssetPath('iconA.png'));
app.dock.setIcon(realmImage);
};
const bootInModeY = () => {
// Vice versa.
};
const bootApp = () => {
// Create a throwaway window so the main process remains open.
const throwawayWindow = new BrowserWindow({
show: false,
});
if (isModeA) {
windowB.close()
bootInModeA();
} else {
windowA.close()
bootInModeB();
}
throwawayWindow.close();
}
The problem is that right-click > "Keep in Dock" pins the same app icon and provides me with no information about what version of the app they want to keep pinned.
I could create a custom "Keep in Dock" MenuItem that stores the last mode with electron-store, however this doesn't allow two different dock icons.
Any pointers appreciated.