Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/app/main.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,13 @@ const STATUS_TEXT_LIMIT = 80;

const smokeTest = process.argv.includes('--smoke-test');
// Started by the `avenue` command for an assistant: stay in the tray, show no window.
const startedHidden = process.argv.includes('--hidden');
// A login launch is also silent: the app waits in the tray until the person opens it.
const startedHidden = process.argv.includes('--hidden') || (process.platform === 'darwin' && app.getLoginItemSettings().wasOpenedAtLogin);
app.setName('Avenue Sync');
if (smokeTest) app.setPath('userData', path.join(os.tmpdir(), `avenue-sync-smoke-${process.pid}`));
if (!smokeTest && !app.requestSingleInstanceLock()) app.exit(0);
app.on('second-instance', (_event, argv) => { if (!argv.includes('--hidden')) showSettings(); });
app.on('activate', () => showSettings());
// No 'activate' handler: macOS activates the app for a clicked notification or an `open -g`, and that must not raise the window. The tray menu opens it.

let tray;
let win;
Expand Down Expand Up @@ -485,7 +486,7 @@ app.whenReady().then(async () => {
createTray();
await startApi();
syncCliCopy(app.getPath('userData'));
app.setLoginItemSettings({ openAtLogin: app.isPackaged && !smokeTest });
app.setLoginItemSettings({ openAtLogin: app.isPackaged && !smokeTest, args: ['--hidden'] });
if (smokeTest) { log('Smoke test passed.'); setTimeout(() => app.exit(0), 500); return; }
sessions.start();
void scheduler.start();
Expand Down
Loading