diff options
author | Kristóf Marussy <kristof@marussy.com> | 2022-05-04 21:50:32 +0200 |
---|---|---|
committer | Kristóf Marussy <kristof@marussy.com> | 2022-05-16 00:55:03 +0200 |
commit | efc32118b6b079462255890a7cb7c2e09ae9d473 (patch) | |
tree | 7bf13f27316c5db78fc6ea38e9a550f9a97452e4 /scripts | |
parent | build: integration testing support (diff) | |
download | sophie-efc32118b6b079462255890a7cb7c2e09ae9d473.tar.gz sophie-efc32118b6b079462255890a7cb7c2e09ae9d473.tar.zst sophie-efc32118b6b079462255890a7cb7c2e09ae9d473.zip |
feat: use wayland when available
Auto-detect wayland in the yarn watch script.
We use a shell script wrapper to launch sophie with wayland-specific
arguments whenever appropriate. Because of this, the electron binary
that ships with sophie has been renamed to sophie-bin.
Signed-off-by: Kristóf Marussy <kristof@marussy.com>
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/watch.js | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/scripts/watch.js b/scripts/watch.js index eeee6e4..5db0d30 100644 --- a/scripts/watch.js +++ b/scripts/watch.js | |||
@@ -1,4 +1,5 @@ | |||
1 | import { spawn } from 'node:child_process'; | 1 | import { spawn } from 'node:child_process'; |
2 | import os from 'node:os'; | ||
2 | import path from 'node:path'; | 3 | import path from 'node:path'; |
3 | 4 | ||
4 | import { watch } from 'chokidar'; | 5 | import { watch } from 'chokidar'; |
@@ -31,7 +32,7 @@ const userDataDir = path.join(thisDir, '../userDataDir/development'); | |||
31 | 32 | ||
32 | /** @type {RegExp[]} */ | 33 | /** @type {RegExp[]} */ |
33 | const stderrIgnorePatterns = [ | 34 | const stderrIgnorePatterns = [ |
34 | // warning about devtools extension | 35 | // Warning about devtools extension |
35 | // https://github.com/cawa-93/vite-electron-builder/issues/492 | 36 | // https://github.com/cawa-93/vite-electron-builder/issues/492 |
36 | // https://github.com/MarshallOfSound/electron-devtools-installer/issues/143 | 37 | // https://github.com/MarshallOfSound/electron-devtools-installer/issues/143 |
37 | /ExtensionLoadWarning/, | 38 | /ExtensionLoadWarning/, |
@@ -44,6 +45,8 @@ const stderrIgnorePatterns = [ | |||
44 | // Does not seem to occur in production | 45 | // Does not seem to occur in production |
45 | // https://github.com/electron/electron/issues/32133#issuecomment-1079916988 | 46 | // https://github.com/electron/electron/issues/32133#issuecomment-1079916988 |
46 | /(sandbox_bundle\.js script failed to run|object null is not iterable).+ node:electron\/js2c\/sandbox_bundle \(160\)$/, | 47 | /(sandbox_bundle\.js script failed to run|object null is not iterable).+ node:electron\/js2c\/sandbox_bundle \(160\)$/, |
48 | // Warning when GPU-accelerated video decoding is not available (some wayland configs) | ||
49 | /Passthrough is not supported, GL is/, | ||
47 | ]; | 50 | ]; |
48 | 51 | ||
49 | /** | 52 | /** |
@@ -134,6 +137,20 @@ function setupMainPackageWatcher(viteDevServer) { | |||
134 | const portOrDefault = port || 3000; | 137 | const portOrDefault = port || 3000; |
135 | process.env.VITE_DEV_SERVER_URL = `${protocol}//${hostOrDefault}:${portOrDefault}/`; | 138 | process.env.VITE_DEV_SERVER_URL = `${protocol}//${hostOrDefault}:${portOrDefault}/`; |
136 | 139 | ||
140 | /** @type {string[]} */ | ||
141 | let extraArgs = []; | ||
142 | |||
143 | if (['aix', 'freebsd', 'linux', 'openbsd', 'sunos'].includes(os.platform())) { | ||
144 | // Use wayland display server if available. | ||
145 | extraArgs = | ||
146 | 'WAYLAND_DISPLAY' in process.env | ||
147 | ? [ | ||
148 | '--enable-features=WaylandWindowDecorations,WebRTCPipeWireCapturer', | ||
149 | '--ozone-platform=wayland', | ||
150 | ] | ||
151 | : ['--ozone-platform=x11']; | ||
152 | } | ||
153 | |||
137 | /** @type {import('child_process').ChildProcessByStdio<null, null, import('stream').Readable> | 154 | /** @type {import('child_process').ChildProcessByStdio<null, null, import('stream').Readable> |
138 | | undefined} */ | 155 | | undefined} */ |
139 | let childProcess; | 156 | let childProcess; |
@@ -144,7 +161,12 @@ function setupMainPackageWatcher(viteDevServer) { | |||
144 | function spawnProcess() { | 161 | function spawnProcess() { |
145 | childProcess = spawn( | 162 | childProcess = spawn( |
146 | String(electronPath), | 163 | String(electronPath), |
147 | ['.', `--user-data-dir=${userDataDir}`, ...process.argv.slice(2)], | 164 | [ |
165 | '.', | ||
166 | `--user-data-dir=${userDataDir}`, | ||
167 | ...extraArgs, | ||
168 | ...process.argv.slice(2), | ||
169 | ], | ||
148 | { | 170 | { |
149 | stdio: ['inherit', 'inherit', 'pipe'], | 171 | stdio: ['inherit', 'inherit', 'pipe'], |
150 | }, | 172 | }, |