mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-04-19 06:43:51 +02:00
Linux: SteamVR overlay support (#1299)
* fix: open folder and select item on linux * feat: linux wrist overlay * feat: linux hmd overlay * feat: replace unix sockets with shm on linux * fix: reduce linux wrist overlay fps * fix: hide electron offscreen windows * fix: destroy electron offscreen windows when not in use * fix: open folder and select item on linux * feat: cpu, uptime and device monitoring on linux * feat: native wayland gl context with x11 fallback on linux * fix: use platform agnostic wording for common folders * fix: crash dumps folder button on linux * fix: enable missing VR notification options on linux * fix: update cef, eslint config to include updated AppApiVr names * merge: rebase linux VR changes to upstream * Clean up * Load custom file contents rather than path Fixes loading custom file in debug mode * fix: call SetVR on linux as well * fix: AppApiVrElectron init, properly create and dispose of shm * Handle avatar history error * Lint * Change overlay dispose logic * macOS DOTNET_ROOT * Remove moving dotnet bin * Fix * fix: init overlay on SteamVR restart * Fix fetching empty instance, fix user dialog not fetching * Trim direct access inputs * Make icon higher res, because mac build would fail 😂 * macOS fixes * will it build? that's the question * fix: ensure offscreen windows are ready before vrinit * will it build? that's the question * will it build? that's the question * meow * one, more, time * Fix crash and overlay ellipsis * a --------- Co-authored-by: Natsumi <cmcooper123@hotmail.com>
This commit is contained in:
@@ -5,88 +5,101 @@ const { spawnSync } = require('child_process');
|
||||
|
||||
const DOTNET_VERSION = '9.0.7';
|
||||
const DOTNET_RUNTIME_URL = `https://builds.dotnet.microsoft.com/dotnet/Runtime/${DOTNET_VERSION}/dotnet-runtime-${DOTNET_VERSION}-linux-x64.tar.gz`;
|
||||
const DOTNET_RUNTIME_DIR = path.join(__dirname, '..', 'build', 'Electron', 'dotnet-runtime');
|
||||
const DOTNET_BIN_DIR = path.join(DOTNET_RUNTIME_DIR, 'bin');
|
||||
const DOTNET_RUNTIME_DIR = path.join(
|
||||
__dirname,
|
||||
'..',
|
||||
'build',
|
||||
'Electron',
|
||||
'dotnet-runtime'
|
||||
);
|
||||
|
||||
async function downloadFile(url, targetPath) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const file = fs.createWriteStream(targetPath);
|
||||
https.get(url, (response) => {
|
||||
if (response.statusCode !== 200) {
|
||||
reject(new Error(`Failed to download, status code: ${response.statusCode}`));
|
||||
return;
|
||||
}
|
||||
response.pipe(file);
|
||||
file.on('finish', () => {
|
||||
file.close(resolve);
|
||||
https
|
||||
.get(url, (response) => {
|
||||
if (response.statusCode !== 200) {
|
||||
reject(
|
||||
new Error(
|
||||
`Failed to download, status code: ${response.statusCode}`
|
||||
)
|
||||
);
|
||||
return;
|
||||
}
|
||||
response.pipe(file);
|
||||
file.on('finish', () => {
|
||||
file.close(resolve);
|
||||
});
|
||||
})
|
||||
.on('error', (err) => {
|
||||
fs.unlink(targetPath, () => reject(err));
|
||||
});
|
||||
}).on('error', (err) => {
|
||||
fs.unlink(targetPath, () => reject(err));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
async function extractTarGz(tarGzPath, extractDir) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const tar = spawnSync('tar', ['-xzf', tarGzPath, '-C', extractDir, '--strip-components=1'], {
|
||||
stdio: 'inherit'
|
||||
});
|
||||
|
||||
const tar = spawnSync(
|
||||
'tar',
|
||||
['-xzf', tarGzPath, '-C', extractDir, '--strip-components=1'],
|
||||
{
|
||||
stdio: 'inherit'
|
||||
}
|
||||
);
|
||||
|
||||
if (tar.status === 0) {
|
||||
resolve();
|
||||
} else {
|
||||
reject(new Error(`tar extraction failed with status ${tar.status}`));
|
||||
reject(
|
||||
new Error(`tar extraction failed with status ${tar.status}`)
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
async function main() {
|
||||
if (process.platform !== 'linux') {
|
||||
console.log('Skipping .NET runtime download on non-Linux platform');
|
||||
return;
|
||||
}
|
||||
|
||||
console.log(`Downloading .NET ${DOTNET_VERSION} runtime...`);
|
||||
|
||||
|
||||
if (!fs.existsSync(DOTNET_RUNTIME_DIR)) {
|
||||
fs.mkdirSync(DOTNET_RUNTIME_DIR, { recursive: true });
|
||||
}
|
||||
if (!fs.existsSync(DOTNET_BIN_DIR)) {
|
||||
fs.mkdirSync(DOTNET_BIN_DIR, { recursive: true });
|
||||
}
|
||||
|
||||
|
||||
const tarGzPath = path.join(DOTNET_RUNTIME_DIR, 'dotnet-runtime.tar.gz');
|
||||
|
||||
|
||||
try {
|
||||
// Download .NET runtime
|
||||
await downloadFile(DOTNET_RUNTIME_URL, tarGzPath);
|
||||
console.log('Download completed');
|
||||
|
||||
|
||||
// Extract .NET runtime to a temporary directory first
|
||||
const tempExtractDir = path.join(DOTNET_RUNTIME_DIR, 'temp');
|
||||
if (!fs.existsSync(tempExtractDir)) {
|
||||
fs.mkdirSync(tempExtractDir, { recursive: true });
|
||||
}
|
||||
|
||||
|
||||
console.log('Extracting .NET runtime...');
|
||||
await extractTarGz(tarGzPath, tempExtractDir);
|
||||
console.log('Extraction completed');
|
||||
|
||||
|
||||
// Clean up tar.gz file
|
||||
fs.unlinkSync(tarGzPath);
|
||||
console.log('Cleanup completed');
|
||||
|
||||
// Move dotnet executable to bin directory
|
||||
|
||||
// Ensure the dotnet executable is executable
|
||||
const extractedDotnet = path.join(tempExtractDir, 'dotnet');
|
||||
const targetDotnet = path.join(DOTNET_BIN_DIR, 'dotnet');
|
||||
|
||||
if (fs.existsSync(extractedDotnet)) {
|
||||
fs.renameSync(extractedDotnet, targetDotnet);
|
||||
fs.chmodSync(targetDotnet, 0o755);
|
||||
console.log('Moved dotnet executable to bin directory');
|
||||
}
|
||||
|
||||
fs.chmodSync(extractedDotnet, 0o755);
|
||||
|
||||
// Move all other files to the root of dotnet-runtime
|
||||
const files = fs.readdirSync(tempExtractDir);
|
||||
for (const file of files) {
|
||||
const sourcePath = path.join(tempExtractDir, file);
|
||||
const targetPath = path.join(DOTNET_RUNTIME_DIR, file);
|
||||
|
||||
|
||||
if (fs.existsSync(targetPath)) {
|
||||
if (fs.lstatSync(sourcePath).isDirectory()) {
|
||||
// Remove existing directory and move new one
|
||||
@@ -96,16 +109,16 @@ async function main() {
|
||||
fs.unlinkSync(targetPath);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fs.renameSync(sourcePath, targetPath);
|
||||
}
|
||||
|
||||
|
||||
// Clean up temp directory
|
||||
fs.rmSync(tempExtractDir, { recursive: true, force: true });
|
||||
|
||||
console.log(`.NET runtime downloaded and extracted to: ${DOTNET_RUNTIME_DIR}`);
|
||||
console.log(`dotnet executable available at: ${targetDotnet}`);
|
||||
|
||||
|
||||
console.log(
|
||||
`.NET runtime downloaded and extracted to: ${DOTNET_RUNTIME_DIR}`
|
||||
);
|
||||
} catch (error) {
|
||||
console.error('Error:', error.message);
|
||||
process.exit(1);
|
||||
@@ -116,4 +129,4 @@ if (require.main === module) {
|
||||
main();
|
||||
}
|
||||
|
||||
module.exports = { downloadFile, extractTarGz };
|
||||
module.exports = { downloadFile, extractTarGz };
|
||||
|
||||
Reference in New Issue
Block a user