|
| 1 | +// Fixe les variables d'environnement terminal si absentes (utile pour AppImage) |
| 2 | +if (!process.env.TERM) process.env.TERM = 'xterm-256color'; |
| 3 | +if (!process.env.COLORTERM) process.env.COLORTERM = 'truecolor'; |
| 4 | + |
1 | 5 | const { app, BrowserWindow, ipcMain, Menu, protocol, shell } = require('electron'); |
2 | 6 | const path = require('path'); |
3 | 7 | const fs = require('fs'); |
@@ -37,16 +41,32 @@ if (!gotTheLock) { |
37 | 41 | } |
38 | 42 |
|
39 | 43 | // --- Gestion accélération GPU (doit être AVANT app.whenReady) --- |
| 44 | +// Vérifier d'abord les arguments de ligne de commande |
| 45 | +const hasDisableGpuFlag = process.argv.includes('--disable-gpu'); |
| 46 | + |
40 | 47 | let disableGpuPref = false; |
41 | 48 | try { |
42 | 49 | const prefPath = path.join(app.getPath('userData'), 'gpu-pref.json'); |
| 50 | + console.log('[GPU DEBUG] Checking GPU pref file at:', prefPath); |
43 | 51 | if (fs.existsSync(prefPath)) { |
44 | 52 | const raw = fs.readFileSync(prefPath, 'utf8'); |
| 53 | + console.log('[GPU DEBUG] File content:', raw); |
45 | 54 | disableGpuPref = JSON.parse(raw).disableGpu === true; |
| 55 | + console.log('[GPU DEBUG] disableGpuPref parsed to:', disableGpuPref); |
| 56 | + } else { |
| 57 | + console.log('[GPU DEBUG] File does not exist'); |
46 | 58 | } |
47 | | -} catch(_){ } |
48 | | -if (disableGpuPref && typeof app.disableHardwareAcceleration === 'function') { |
| 59 | +} catch(e){ |
| 60 | + console.log('[GPU DEBUG] Error reading GPU pref:', e); |
| 61 | +} |
| 62 | + |
| 63 | +// Désactiver GPU si demandé par flag CLI ou par préférence |
| 64 | +const shouldDisableGpu = hasDisableGpuFlag || disableGpuPref; |
| 65 | +if (shouldDisableGpu && typeof app.disableHardwareAcceleration === 'function') { |
| 66 | + console.log('[GPU DEBUG] Calling app.disableHardwareAcceleration() - reason:', hasDisableGpuFlag ? 'CLI flag' : 'user preference'); |
49 | 67 | app.disableHardwareAcceleration(); |
| 68 | +} else { |
| 69 | + console.log('[GPU DEBUG] NOT calling app.disableHardwareAcceleration(), shouldDisable:', shouldDisableGpu, 'function exists:', typeof app.disableHardwareAcceleration === 'function'); |
50 | 70 | } |
51 | 71 |
|
52 | 72 | const errorLogPath = path.join(app.getPath('userData'), 'error.log'); |
@@ -209,7 +229,7 @@ function buildSandboxAnswerScript(shouldConfigure, dirSelections, customPath) { |
209 | 229 |
|
210 | 230 | function runSandboxTask(sender, { pm, action, args, stdinScript, appName }) { |
211 | 231 | return new Promise((resolve) => { |
212 | | - const pty = require('node-pty'); |
| 232 | + const pty = require('@homebridge/node-pty-prebuilt-multiarch'); |
213 | 233 | const id = `${action}-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 7)}`; |
214 | 234 | const env = Object.assign({}, process.env, { |
215 | 235 | TERM: 'xterm', |
@@ -309,6 +329,12 @@ ipcMain.handle('set-gpu-pref', async (_event, val) => { |
309 | 329 | } catch(e){ return { ok:false, error: e.message||String(e) }; } |
310 | 330 | }); |
311 | 331 |
|
| 332 | +// IPC pour redémarrer l'application (utilisé après changement GPU) |
| 333 | +ipcMain.handle('restart-app', async () => { |
| 334 | + app.relaunch(); |
| 335 | + app.quit(); |
| 336 | +}); |
| 337 | + |
312 | 338 | function createWindow () { |
313 | 339 | // Détection simple de l'environnement de bureau pour stylage léger |
314 | 340 | function detectDesktopEnv() { |
@@ -463,7 +489,7 @@ ipcMain.handle('am-action', async (event, action, software) => { |
463 | 489 |
|
464 | 490 | return new Promise((resolve) => { |
465 | 491 | try { |
466 | | - const pty = require('node-pty'); |
| 492 | + const pty = require('@homebridge/node-pty-prebuilt-multiarch'); |
467 | 493 | const env = Object.assign({}, process.env, { |
468 | 494 | TERM: 'xterm', |
469 | 495 | COLS: '80', |
@@ -543,7 +569,7 @@ ipcMain.handle('install-start', async (event, name) => { |
543 | 569 | const startedAt = Date.now(); |
544 | 570 | let stdoutRemainder = ''; |
545 | 571 | let stderrRemainder = ''; |
546 | | - const pty = require('node-pty'); |
| 572 | + const pty = require('@homebridge/node-pty-prebuilt-multiarch'); |
547 | 573 | const env = Object.assign({}, process.env, { |
548 | 574 | TERM: 'xterm', |
549 | 575 | COLS: '80', |
@@ -695,7 +721,7 @@ ipcMain.handle('updates-start', async (event) => { |
695 | 721 | const id = Date.now().toString(36) + '-' + Math.random().toString(36).slice(2,8); |
696 | 722 | let child; |
697 | 723 | let output = ''; |
698 | | - const pty = require('node-pty'); |
| 724 | + const pty = require('@homebridge/node-pty-prebuilt-multiarch'); |
699 | 725 | const env = Object.assign({}, process.env, { |
700 | 726 | TERM: 'xterm', |
701 | 727 | COLS: '80', |
|
0 commit comments