-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
73 lines (63 loc) · 1.78 KB
/
main.js
File metadata and controls
73 lines (63 loc) · 1.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
const { app, BrowserWindow, ipcMain } = require("electron");
const path = require("path");
const AutoLaunch = require("auto-launch");
const Store = require("electron-store");
// Initialize electron-store
const store = new Store();
// Configure auto-launch
const autoLauncher = new AutoLaunch({
name: "GCG Widget",
path: app.getPath("exe"),
});
// Enable auto-launch on first run
autoLauncher.isEnabled().then((isEnabled) => {
if (!isEnabled) {
autoLauncher.enable();
console.log("Auto-launch enabled");
}
}).catch((err) => {
console.error("Error checking auto-launch status:", err);
});
function createWindow() {
const win = new BrowserWindow({
width: 340,
height: 220, // Increased slightly to fit month labels
frame: false,
transparent: true,
resizable: true,
hasShadow: false,
skipTaskbar: true,
minWidth: 200,
minHeight: 220, // Lock height
maxHeight: 220, // Lock height
alwaysOnTop: false,
webPreferences: {
nodeIntegration: true,
contextIsolation: false,
},
});
win.loadFile("index.html");
// Optional: Add IPC handler to toggle auto-launch from renderer
ipcMain.handle("toggle-auto-launch", async () => {
const isEnabled = await autoLauncher.isEnabled();
if (isEnabled) {
await autoLauncher.disable();
return false;
} else {
await autoLauncher.enable();
return true;
}
});
ipcMain.handle("get-auto-launch-status", async () => {
return await autoLauncher.isEnabled();
});
// Username management handlers
ipcMain.handle("get-username", () => {
return store.get("githubUsername", null);
});
ipcMain.handle("set-username", (event, username) => {
store.set("githubUsername", username);
return true;
});
}
app.whenReady().then(createWindow);