Skip to content

Commit 541477f

Browse files
authored
Merge pull request #16 from Shikakiben/test
Test
2 parents 8029a69 + bedf618 commit 541477f

File tree

13 files changed

+5107
-272
lines changed

13 files changed

+5107
-272
lines changed

.github/workflows/appimage.yml

Lines changed: 83 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ name: Anylinux-AppImage
22
concurrency:
33
group: build-${{ github.ref }}
44
cancel-in-progress: true
5+
6+
env:
7+
VERSION: beta-0.${{ github.run_number }}
8+
59
on:
610
push:
711
branches:
@@ -10,10 +14,57 @@ on:
1014
- cron: "0 7 1/21 * *" # We default to rebuilding every 21 days, change this to your liking
1115
workflow_dispatch: {}
1216

17+
1318
jobs:
19+
build-prebuild-glibc:
20+
name: Build prebuild glibc
21+
runs-on: ubuntu-latest
22+
container: ubuntu:20.04
23+
steps:
24+
- uses: actions/checkout@v5
25+
- name: Install build tools
26+
run: |
27+
export DEBIAN_FRONTEND=noninteractive
28+
apt-get update && apt-get install -y build-essential python3 gcc-10 g++-10 curl
29+
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10 100
30+
update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-10 100
31+
- name: build AM-GUI
32+
run: |
33+
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.3/install.sh | bash
34+
. "$HOME/.nvm/nvm.sh"
35+
nvm install 22
36+
node -v
37+
npm -v
38+
npm install --ignore-scripts
39+
npx electron-rebuild --force
40+
- name: Upload prebuild
41+
uses: actions/upload-artifact@v5
42+
with:
43+
name: prebuild-glibc
44+
path: node_modules/@homebridge/node-pty-prebuilt-multiarch/build/Release/pty.node
45+
46+
build-prebuild-musl:
47+
name: Build prebuild musl
48+
runs-on: ubuntu-latest
49+
container: node:22-alpine
50+
steps:
51+
- uses: actions/checkout@v5
52+
- name: Install build tools
53+
run: apk add --no-cache python3 make g++ linux-headers
54+
- name: build AM-GUI
55+
run: |
56+
npm install --ignore-scripts
57+
npx electron-rebuild --force
58+
- name: Upload prebuild
59+
uses: actions/upload-artifact@v5
60+
with:
61+
name: prebuild-musl
62+
path: node_modules/@homebridge/node-pty-prebuilt-multiarch/build/Release/pty.node
63+
1464
build:
1565
name: "${{ matrix.name }} (${{ matrix.arch }})"
1666
runs-on: ${{ matrix.runs-on }}
67+
needs: [build-prebuild-glibc, build-prebuild-musl]
1768
strategy:
1869
matrix:
1970
include:
@@ -23,12 +74,42 @@ jobs:
2374
# comment out these 3 lines if aarch64 is not wanted
2475
# - runs-on: ubuntu-24.04-arm
2576
# name: Build AppImage
26-
# arch: aarch64
77+
# arch: aarch64
78+
2779
container: ghcr.io/pkgforge-dev/archlinux:latest
2880
steps:
29-
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
81+
- uses: actions/checkout@v5
3082
- name: Preparing Container
3183
uses: pkgforge-dev/anylinux-setup-action@8872fabe63f9a00b35e25b2f46da62a05afc9a7d # v1
84+
- name: Setup Node
85+
run: |
86+
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.3/install.sh | bash
87+
. "$HOME/.nvm/nvm.sh"
88+
nvm install 22
89+
node -v
90+
npm -v
91+
npm install
92+
npx patch-package
93+
- name: Download prebuilds glibc
94+
uses: actions/download-artifact@v5
95+
with:
96+
name: prebuild-glibc
97+
path: temp-glibc
98+
- name: Download prebuilds musl
99+
uses: actions/download-artifact@v5
100+
with:
101+
name: prebuild-musl
102+
path: temp-musl
103+
- name: Place prebuilds
104+
run: |
105+
rm -rf node_modules/@homebridge/node-pty-prebuilt-multiarch/prebuilds
106+
mkdir -p node_modules/@homebridge/node-pty-prebuilt-multiarch/prebuilds/linux-x64
107+
cp temp-glibc/pty.node node_modules/@homebridge/node-pty-prebuilt-multiarch/prebuilds/linux-x64/pty.node
108+
cp temp-musl/pty.node node_modules/@homebridge/node-pty-prebuilt-multiarch/prebuilds/linux-x64/pty-musl.node
109+
- name: Run dist
110+
run: |
111+
. "$HOME/.nvm/nvm.sh"
112+
npm run dist
32113
- name: Install Dependencies
33114
run: /bin/sh ./scripts/get-dependencies.sh
34115
- name: Make AppImage

AM-GUI.desktop

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[Desktop Entry]
22
Type=Application
33
Name=AM-GUI
4-
Exec=bin/start-am-gui.sh
4+
Exec=am-gui %U
55
Icon=AM-GUI.png
66
StartupWMClass=AM-GUI
77
Terminal=false

AM-INSTALLER

Lines changed: 0 additions & 106 deletions
This file was deleted.

bin/start-am-gui.sh

Lines changed: 0 additions & 5 deletions
This file was deleted.

main.js

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
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+
15
const { app, BrowserWindow, ipcMain, Menu, protocol, shell } = require('electron');
26
const path = require('path');
37
const fs = require('fs');
@@ -37,16 +41,32 @@ if (!gotTheLock) {
3741
}
3842

3943
// --- 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+
4047
let disableGpuPref = false;
4148
try {
4249
const prefPath = path.join(app.getPath('userData'), 'gpu-pref.json');
50+
console.log('[GPU DEBUG] Checking GPU pref file at:', prefPath);
4351
if (fs.existsSync(prefPath)) {
4452
const raw = fs.readFileSync(prefPath, 'utf8');
53+
console.log('[GPU DEBUG] File content:', raw);
4554
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');
4658
}
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');
4967
app.disableHardwareAcceleration();
68+
} else {
69+
console.log('[GPU DEBUG] NOT calling app.disableHardwareAcceleration(), shouldDisable:', shouldDisableGpu, 'function exists:', typeof app.disableHardwareAcceleration === 'function');
5070
}
5171

5272
const errorLogPath = path.join(app.getPath('userData'), 'error.log');
@@ -209,7 +229,7 @@ function buildSandboxAnswerScript(shouldConfigure, dirSelections, customPath) {
209229

210230
function runSandboxTask(sender, { pm, action, args, stdinScript, appName }) {
211231
return new Promise((resolve) => {
212-
const pty = require('node-pty');
232+
const pty = require('@homebridge/node-pty-prebuilt-multiarch');
213233
const id = `${action}-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 7)}`;
214234
const env = Object.assign({}, process.env, {
215235
TERM: 'xterm',
@@ -309,6 +329,12 @@ ipcMain.handle('set-gpu-pref', async (_event, val) => {
309329
} catch(e){ return { ok:false, error: e.message||String(e) }; }
310330
});
311331

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+
312338
function createWindow () {
313339
// Détection simple de l'environnement de bureau pour stylage léger
314340
function detectDesktopEnv() {
@@ -463,7 +489,7 @@ ipcMain.handle('am-action', async (event, action, software) => {
463489

464490
return new Promise((resolve) => {
465491
try {
466-
const pty = require('node-pty');
492+
const pty = require('@homebridge/node-pty-prebuilt-multiarch');
467493
const env = Object.assign({}, process.env, {
468494
TERM: 'xterm',
469495
COLS: '80',
@@ -543,7 +569,7 @@ ipcMain.handle('install-start', async (event, name) => {
543569
const startedAt = Date.now();
544570
let stdoutRemainder = '';
545571
let stderrRemainder = '';
546-
const pty = require('node-pty');
572+
const pty = require('@homebridge/node-pty-prebuilt-multiarch');
547573
const env = Object.assign({}, process.env, {
548574
TERM: 'xterm',
549575
COLS: '80',
@@ -695,7 +721,7 @@ ipcMain.handle('updates-start', async (event) => {
695721
const id = Date.now().toString(36) + '-' + Math.random().toString(36).slice(2,8);
696722
let child;
697723
let output = '';
698-
const pty = require('node-pty');
724+
const pty = require('@homebridge/node-pty-prebuilt-multiarch');
699725
const env = Object.assign({}, process.env, {
700726
TERM: 'xterm',
701727
COLS: '80',

0 commit comments

Comments
 (0)