cicy-desktop 2.1.43 → 2.1.44
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/main.js +41 -7
package/package.json
CHANGED
package/src/main.js
CHANGED
|
@@ -547,17 +547,29 @@ function ensureWindowsDesktopLauncher() {
|
|
|
547
547
|
// Honors `prefs.openAtLogin` if present; defaults to true on first run.
|
|
548
548
|
function ensureAutoLaunch() {
|
|
549
549
|
try {
|
|
550
|
-
if (!electronApp.isPackaged) return; // dev mode: don't touch login items
|
|
551
550
|
const prefs = readPrefs();
|
|
552
551
|
const want = prefs.openAtLogin !== false; // default true
|
|
553
|
-
|
|
552
|
+
|
|
553
|
+
if (process.platform === "darwin") {
|
|
554
|
+
// mac: register the STABLE Desktop applet as a login item — works for
|
|
555
|
+
// npx/global installs (isPackaged=false), not just packaged .apps. We
|
|
556
|
+
// register the applet (a fixed path that internally runs the global
|
|
557
|
+
// cicy-desktop bin) instead of process.execPath, which is a transient
|
|
558
|
+
// electron path that breaks on every version/cache change (the old auto-
|
|
559
|
+
// start bug). Skip a pure source checkout so devs aren't auto-added.
|
|
560
|
+
const installed = electronApp.isPackaged ||
|
|
561
|
+
__dirname.includes(`${path.sep}node_modules${path.sep}`);
|
|
562
|
+
if (!installed) return;
|
|
563
|
+
ensureMacLoginItem(want);
|
|
564
|
+
return;
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
// win/linux: unchanged — only manage login items for packaged builds.
|
|
568
|
+
if (!electronApp.isPackaged) return;
|
|
569
|
+
if (process.platform === "win32") {
|
|
554
570
|
const cur = electronApp.getLoginItemSettings();
|
|
555
571
|
if (cur.openAtLogin !== want) {
|
|
556
|
-
electronApp.setLoginItemSettings({
|
|
557
|
-
openAtLogin: want,
|
|
558
|
-
// Windows: pass --hidden so the app starts to the tray, not foreground.
|
|
559
|
-
args: process.platform === "win32" ? ["--hidden"] : undefined,
|
|
560
|
-
});
|
|
572
|
+
electronApp.setLoginItemSettings({ openAtLogin: want, args: ["--hidden"] });
|
|
561
573
|
log.info(`[autostart] openAtLogin → ${want}`);
|
|
562
574
|
}
|
|
563
575
|
} else if (process.platform === "linux") {
|
|
@@ -568,6 +580,28 @@ function ensureAutoLaunch() {
|
|
|
568
580
|
}
|
|
569
581
|
}
|
|
570
582
|
|
|
583
|
+
// mac login item pointing at the Desktop applet (~/Desktop/CiCy Desktop.app).
|
|
584
|
+
// The applet is created by the launcher (bin/cicy-desktop ensureMacDesktopApp)
|
|
585
|
+
// BEFORE electron spawns, so it exists by the time this runs. Idempotent:
|
|
586
|
+
// always clears a stale entry first, then (re)adds when wanted.
|
|
587
|
+
function ensureMacLoginItem(want) {
|
|
588
|
+
const name = "CiCy Desktop";
|
|
589
|
+
const appletPath = path.join(os.homedir(), "Desktop", "CiCy Desktop.app");
|
|
590
|
+
try {
|
|
591
|
+
const { execFileSync } = require("child_process");
|
|
592
|
+
const osa = (script) => execFileSync("osascript", ["-e", script], { stdio: "ignore" });
|
|
593
|
+
osa(`tell application "System Events" to if login item "${name}" exists then delete login item "${name}"`);
|
|
594
|
+
if (want && fs.existsSync(appletPath)) {
|
|
595
|
+
osa(`tell application "System Events" to make login item at end with properties {name:"${name}", path:"${appletPath}", hidden:false}`);
|
|
596
|
+
log.info(`[autostart] mac login item → ${appletPath}`);
|
|
597
|
+
} else {
|
|
598
|
+
log.info(`[autostart] mac login item ${want ? "skipped (applet missing)" : "removed"}`);
|
|
599
|
+
}
|
|
600
|
+
} catch (e) {
|
|
601
|
+
log.warn(`[autostart] mac login item failed: ${e.message}`);
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
|
|
571
605
|
function readPrefs() {
|
|
572
606
|
try {
|
|
573
607
|
const p = path.join(electronApp.getPath("userData"), "prefs.json");
|