feat: main.js — wires tray, HUD, wakeword, shortcuts and IPC
parent
6f3f770783
commit
a80068b04b
|
|
@ -0,0 +1,53 @@
|
|||
const { app, ipcMain, globalShortcut, nativeTheme } = require('electron');
|
||||
const { createTray } = require('./tray');
|
||||
const { createHud, showHud, hideHud } = require('./hud');
|
||||
const { startWakeword, stopWakeword } = require('./wakeword');
|
||||
const { executeMacCommand } = require('./mac-agent');
|
||||
const axios = require('axios');
|
||||
|
||||
const FOX_URL = process.env.FOX_URL || 'https://fox.pxo.at';
|
||||
|
||||
app.dock?.hide();
|
||||
|
||||
if (!app.requestSingleInstanceLock()) {
|
||||
app.quit();
|
||||
}
|
||||
|
||||
app.whenReady().then(() => {
|
||||
nativeTheme.themeSource = 'dark';
|
||||
|
||||
createHud();
|
||||
|
||||
createTray({
|
||||
onShow: showHud,
|
||||
onHide: hideHud,
|
||||
onQuit: () => app.quit(),
|
||||
});
|
||||
|
||||
globalShortcut.register('CommandOrControl+Shift+F', showHud);
|
||||
|
||||
startWakeword({ onWake: showHud });
|
||||
|
||||
ipcMain.on('hide-hud', () => hideHud());
|
||||
|
||||
ipcMain.on('send-message', async (_, text) => {
|
||||
try {
|
||||
await axios.post(`${FOX_URL}/fox/message`, { text });
|
||||
} catch (err) {
|
||||
console.error('[Fox] send-message fehlgeschlagen:', err.message);
|
||||
}
|
||||
});
|
||||
|
||||
ipcMain.handle('mac-command', async (_, command) => {
|
||||
return await executeMacCommand(command);
|
||||
});
|
||||
});
|
||||
|
||||
app.on('will-quit', () => {
|
||||
globalShortcut.unregisterAll();
|
||||
stopWakeword();
|
||||
});
|
||||
|
||||
app.on('window-all-closed', (e) => {
|
||||
e.preventDefault();
|
||||
});
|
||||
Loading…
Reference in New Issue