From 60d382a135f7f9aefb5bb7da87d5cd4b669f41d5 Mon Sep 17 00:00:00 2001 From: Andrew Zambazos Date: Sun, 28 Dec 2025 22:13:07 +1300 Subject: [PATCH] Game Mode compatability - Browser will now launch into big picture mode if device is in game mode - Controllers work --- README-STEAM.md | 4 ++ documentation/BIG_PICTURE_MODE.md | 8 ++++ main.js | 61 ++++++++++++++++++++++++++++++- 3 files changed, 71 insertions(+), 2 deletions(-) diff --git a/README-STEAM.md b/README-STEAM.md index 5714975..203291b 100644 --- a/README-STEAM.md +++ b/README-STEAM.md @@ -42,3 +42,7 @@ Notes - `--no-sandbox` reduces Chromium sandboxing; prefer fixing `chrome-sandbox` and enabling sandboxing when possible. - Using the AppDir avoids AppImage/FUSE dependency on target systems. - Test on a clean SteamOS/Deck image before publishing. + +Big Picture auto-start (SteamOS Gaming Mode) +- If Nebula is launched from SteamOS Gaming Mode, it will auto-start in Big Picture Mode. +- To force/disable via Steam Launch Options: `--big-picture` or `--no-big-picture`. diff --git a/documentation/BIG_PICTURE_MODE.md b/documentation/BIG_PICTURE_MODE.md index 6367469..f84e4bd 100644 --- a/documentation/BIG_PICTURE_MODE.md +++ b/documentation/BIG_PICTURE_MODE.md @@ -42,6 +42,14 @@ Nebula Browser includes a **Big Picture Mode** - a controller-friendly, console- ### Automatic Detection If Nebula detects a Steam Deck-sized display (1280x800), it will suggest Big Picture Mode in settings. +### Auto-start in SteamOS Gaming Mode +When Nebula is launched from SteamOS **Gaming Mode** (gamescope / Steam gamepad UI), it will automatically start in **Big Picture Mode**. + +You can override this behavior: +- Force Big Picture at launch: launch options `--big-picture` (or `--bigpicture`) +- Disable Big Picture auto-start: launch options `--no-big-picture` (or `--no-bigpicture`) +- Environment overrides: `NEBULA_BIG_PICTURE=1` / `NEBULA_NO_BIG_PICTURE=1` + ## Navigation Sections | Section | Description | diff --git a/main.js b/main.js index 82088eb..7ae02c3 100644 --- a/main.js +++ b/main.js @@ -72,6 +72,53 @@ ipcMain.removeHandler('window-close'); // BIG PICTURE MODE - Steam Deck / Console UI // ============================================================================= +function envTruthy(value) { + if (value === undefined || value === null) return false; + const s = String(value).trim().toLowerCase(); + return s === '1' || s === 'true' || s === 'yes' || s === 'on'; +} + +function argvHasFlag(flag) { + return process.argv.includes(flag); +} + +/** + * Heuristic: detect Steam Deck / SteamOS Gaming Mode (gamescope) launches. + * + * This is intentionally conservative and only used for picking the *default* + * startup UI. Users can override via CLI/env. + */ +function isGameModeEnvironment() { + const env = process.env; + + // Common Steam tenfoot / gamepad UI markers + if (envTruthy(env.STEAM_GAMEPADUI)) return true; + if (envTruthy(env.SteamTenfoot)) return true; + if (envTruthy(env.STEAM_TENFOOT)) return true; + + // SteamOS / gamescope compositor markers + const currentDesktop = String(env.XDG_CURRENT_DESKTOP || '').toLowerCase(); + const sessionDesktop = String(env.XDG_SESSION_DESKTOP || '').toLowerCase(); + if (currentDesktop.includes('gamescope') || sessionDesktop.includes('gamescope')) return true; + + if (env.GAMESCOPE_WSI || env.GAMESCOPE_SESSION || env.GAMESCOPE_FOCUSED_APP) return true; + + return false; +} + +function shouldStartInBigPictureMode() { + // Explicit CLI overrides first + if (argvHasFlag('--no-big-picture') || argvHasFlag('--no-bigpicture')) return false; + if (argvHasFlag('--big-picture') || argvHasFlag('--bigpicture') || argvHasFlag('--tenfoot') || argvHasFlag('--game-mode')) return true; + + // Explicit env overrides + if (envTruthy(process.env.NEBULA_NO_BIG_PICTURE) || envTruthy(process.env.NEBULA_NO_BIGPICTURE)) return false; + if (envTruthy(process.env.NEBULA_BIG_PICTURE) || envTruthy(process.env.NEBULA_BIGPICTURE) || envTruthy(process.env.NEBULA_GAME_MODE)) return true; + + // Auto-detect SteamOS Gaming Mode + return isGameModeEnvironment(); +} + // Steam Deck screen dimensions: 1280x800 const STEAM_DECK_WIDTH = 1280; const STEAM_DECK_HEIGHT = 800; @@ -503,7 +550,17 @@ function configureSessionsAsync() { app.whenReady().then(() => { const t0 = performance.now(); - createWindow(); + + // If launched via SteamOS Gaming Mode / gamepad UI, default to Big Picture Mode. + // Desktop launches remain unchanged. + const startInBigPicture = shouldStartInBigPictureMode(); + if (startInBigPicture) { + console.log('[Startup] Detected game mode launch; starting in Big Picture Mode'); + createBigPictureWindow(); + } else { + createWindow(); + } + // Initialize user plugins after app ready try { pluginManager.ensureUserPluginsDir(); @@ -512,7 +569,7 @@ app.whenReady().then(() => { } catch (e) { console.error('[Plugins] initialization error:', e); } - console.log('[Startup] createWindow invoked in', (performance.now() - t0).toFixed(1), 'ms after app.whenReady'); + console.log('[Startup] initial window created (', startInBigPicture ? 'bigpicture' : 'desktop', ') in', (performance.now() - t0).toFixed(1), 'ms after app.whenReady'); // Handle GPU process crashes (still register early) app.on('gpu-process-crashed', (event, killed) => {