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', (_, text) => { 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(); });