Various Changes
- Added support for Streamdeck Pedal - Changed UI to Packed Theme - Added preview for knobs (Loupedeck Live) - Added Start to Tray - Added Udev Rules for Streamdeck Pedal
This commit is contained in:
56
main.js
56
main.js
@@ -10,6 +10,8 @@ import { PedalPageManager } from './src/streamdeck/pages.js';
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = path.dirname(__filename);
|
||||
const START_IN_TRAY_ARG = '--start-in-tray';
|
||||
const startInTray = process.argv.includes(START_IN_TRAY_ARG);
|
||||
|
||||
function getTrayIcon() {
|
||||
const iconPath = path.join(__dirname, 'assets', 'icons', 'Icon.png');
|
||||
@@ -25,13 +27,23 @@ let deviceStatus = { connected: false };
|
||||
let pedalDevice;
|
||||
let pedalPageManager;
|
||||
let pedalStatus = { connected: false };
|
||||
const startupWarnings = new Map();
|
||||
|
||||
function createWindow() {
|
||||
function pushRuntimeWarning(data) {
|
||||
if (!data || !data.code) return;
|
||||
startupWarnings.set(data.code, data);
|
||||
if (mainWindow && !mainWindow.isDestroyed() && mainWindow.webContents) {
|
||||
mainWindow.webContents.send('runtime-warning', data);
|
||||
}
|
||||
}
|
||||
|
||||
function createWindow(startHidden = false) {
|
||||
mainWindow = new BrowserWindow({
|
||||
width: 1580,
|
||||
height: 800,
|
||||
minWidth: 1380,
|
||||
minHeight: 600,
|
||||
show: !startHidden,
|
||||
frame: false,
|
||||
icon: path.join(__dirname, 'assets', 'icons', 'Icon.png'),
|
||||
webPreferences: {
|
||||
@@ -47,6 +59,10 @@ function createWindow() {
|
||||
|
||||
mainWindow.webContents.on('did-finish-load', () => {
|
||||
mainWindow.webContents.send('device-status', deviceStatus);
|
||||
mainWindow.webContents.send('pedal-status', pedalStatus);
|
||||
startupWarnings.forEach((warning) => {
|
||||
mainWindow.webContents.send('runtime-warning', warning);
|
||||
});
|
||||
});
|
||||
|
||||
mainWindow.on('close', (event) => {
|
||||
@@ -57,6 +73,19 @@ function createWindow() {
|
||||
});
|
||||
}
|
||||
|
||||
function applyAutostartToTraySetting(enabled) {
|
||||
const openAtLogin = !!enabled;
|
||||
try {
|
||||
app.setLoginItemSettings({
|
||||
openAtLogin,
|
||||
openAsHidden: openAtLogin,
|
||||
args: openAtLogin ? [START_IN_TRAY_ARG] : []
|
||||
});
|
||||
} catch (error) {
|
||||
console.warn('Could not set login item settings:', error.message);
|
||||
}
|
||||
}
|
||||
|
||||
function createTray() {
|
||||
tray = new Tray(getTrayIcon());
|
||||
const contextMenu = Menu.buildFromTemplate([
|
||||
@@ -69,8 +98,11 @@ function createTray() {
|
||||
}
|
||||
|
||||
async function initializeLoupedeck() {
|
||||
configManager = new ConfigManager();
|
||||
await configManager.load();
|
||||
if (!configManager) {
|
||||
configManager = new ConfigManager();
|
||||
await configManager.load();
|
||||
}
|
||||
applyAutostartToTraySetting(configManager.getSetting('autostartToTray'));
|
||||
|
||||
pageManager = new PageManager(configManager);
|
||||
|
||||
@@ -106,6 +138,10 @@ async function initializeLoupedeck() {
|
||||
mainWindow.webContents.send('button-toggle', data);
|
||||
});
|
||||
|
||||
loupedeckDevice.on('runtime-warning', (data) => {
|
||||
pushRuntimeWarning(data);
|
||||
});
|
||||
|
||||
await loupedeckDevice.connect();
|
||||
}
|
||||
|
||||
@@ -127,6 +163,10 @@ async function initializePedal() {
|
||||
mainWindow.webContents.send('pedal-button-press', data);
|
||||
});
|
||||
|
||||
pedalDevice.on('runtime-warning', (data) => {
|
||||
pushRuntimeWarning(data);
|
||||
});
|
||||
|
||||
await pedalDevice.connect();
|
||||
}
|
||||
|
||||
@@ -329,6 +369,9 @@ ipcMain.handle('reconnect-device', async () => {
|
||||
ipcMain.handle('set-setting', async (event, { key, value }) => {
|
||||
const previousAccent = key === 'accentColor' ? configManager.getSetting('accentColor') : null;
|
||||
configManager.setSetting(key, value);
|
||||
if (key === 'autostartToTray') {
|
||||
applyAutostartToTraySetting(value);
|
||||
}
|
||||
if (key === 'accentColor') {
|
||||
const config = configManager.getConfig();
|
||||
if (Array.isArray(config.pages)) {
|
||||
@@ -413,7 +456,10 @@ ipcMain.handle('window-close', () => {
|
||||
});
|
||||
|
||||
app.whenReady().then(async () => {
|
||||
createWindow();
|
||||
configManager = new ConfigManager();
|
||||
await configManager.load();
|
||||
const startHidden = startInTray || !!configManager.getSetting('autostartToTray');
|
||||
createWindow(startHidden);
|
||||
|
||||
// Tray nur bauen, wenn das Icon da ist
|
||||
try {
|
||||
@@ -427,7 +473,7 @@ app.whenReady().then(async () => {
|
||||
|
||||
app.on('activate', () => {
|
||||
if (BrowserWindow.getAllWindows().length === 0) {
|
||||
createWindow();
|
||||
createWindow(false);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user