feat(desktop): add automatic game/app activity detection
Add cross-platform process scanning that detects running games and apps, then broadcasts them as Rich Presence activities via the existing Phase 1 pipeline (activityStore -> WS -> other users). - games.json dictionary with 26 entries (games, Spotify, VLC, OBS) - activityDetector module: polls OS process list every 15s via execFile, matches against dictionary, emits IPC on state change only - IPC bridge in main.ts/preload.ts with cleanup on quit - Frontend activityBridge subscribes to IPC and feeds activityStore - Supports Windows (tasklist CSV), macOS (ps -c), Linux (ps)
This commit is contained in:
@@ -13,6 +13,7 @@ import {
|
||||
} from 'electron';
|
||||
import path from 'path';
|
||||
import fs from 'fs';
|
||||
import { startActivityDetection, stopActivityDetection, getCurrentActivity } from './activityDetector';
|
||||
|
||||
let mainWindow: BrowserWindow | null = null;
|
||||
let tray: Tray | null = null;
|
||||
@@ -774,6 +775,13 @@ if (!gotTheLock) {
|
||||
createTray();
|
||||
initAutoUpdater();
|
||||
|
||||
// ─── Activity Detection ────────────────────────────────────────────────
|
||||
startActivityDetection((activity) => {
|
||||
mainWindow?.webContents.send('activity-detected', activity);
|
||||
});
|
||||
|
||||
ipcMain.handle('get-current-activity', () => getCurrentActivity());
|
||||
|
||||
// Sync auto-launch settings with OS on startup (refreshes login item path for AppImage updates)
|
||||
const autoLaunchSettings = loadAutoLaunchSettings();
|
||||
applyLoginItemSettings(autoLaunchSettings.openAtLogin, autoLaunchSettings.startMinimized);
|
||||
@@ -801,5 +809,6 @@ if (!gotTheLock) {
|
||||
|
||||
app.on('before-quit', () => {
|
||||
isQuitting = true;
|
||||
stopActivityDetection();
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user