Skip to content

Commit

Permalink
feat: #122 - minmized startup only on OS startup, added minimized arg…
Browse files Browse the repository at this point in the history
…ument
  • Loading branch information
Venipa committed Feb 2, 2025
1 parent 993ae11 commit b72ba1f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
12 changes: 9 additions & 3 deletions src/main/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ const runApp = async function () {
serviceCollection.exec("AfterInit");
}
}
}
};
// Quit when all windows are closed.
app.on("window-all-closed", () => {
// On macOS it is common for applications and their menu bar
Expand All @@ -306,8 +306,14 @@ const runApp = async function () {
await waitMs(); // next tick
mainWindow = await createRootWindow();
await waitMs(); // next tick
const startupService = serviceCollection.getProvider("startup")
if (!startupService.isEnabled || !startupService.isInitialMinimized) mainWindow.main.show();
const startupService = serviceCollection.getProvider("startup");
log.debug({ isStartupContext: startupService.isStartupContext });
if (
startupService.isStartupContext
? !startupService.isEnabled || !startupService.isInitialMinimized
: !startupService.isMinimizedArg
)
mainWindow.main.show();
serviceCollection.providers.forEach((p) => p.__registerWindows(mainWindow));
serviceCollection.exec("AfterInit");
});
Expand Down
8 changes: 7 additions & 1 deletion src/main/plugins/startupProvider.plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,13 @@ export default class StartupProvider extends BaseProvider implements AfterInit,
}
}
private get startArgs() {
return ["--processStart", `"${basename(process.execPath)}"`];
return ["--processStart", `"${basename(process.execPath)}"`, "--startup"];
}
get isStartupContext() {
return !!process.argv.find(arg => arg === "--startup");
}
get isMinimizedArg() {
return !!process.argv.find(arg => arg === "--minimized");
}
async AfterInit() {
const app = this.settingsInstance.instance.app;
Expand Down

0 comments on commit b72ba1f

Please sign in to comment.