proper fix for disabling sandbox on steamos
This commit is contained in:
parent
9521c287b6
commit
cc8b5dd725
2 changed files with 47 additions and 0 deletions
|
@ -68,6 +68,7 @@
|
||||||
"package.json",
|
"package.json",
|
||||||
"LICENSE"
|
"LICENSE"
|
||||||
],
|
],
|
||||||
|
"afterPack": "scripts/build/fixSandbox.js",
|
||||||
"linux": {
|
"linux": {
|
||||||
"icon": "build/icon.icns",
|
"icon": "build/icon.icns",
|
||||||
"category": "Network",
|
"category": "Network",
|
||||||
|
|
46
scripts/build/fixSandbox.js
Normal file
46
scripts/build/fixSandbox.js
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
/*
|
||||||
|
* SPDX-License-Identifier: GPL-3.0
|
||||||
|
* Vesktop, a desktop app aiming to give you a snappier Discord Experience
|
||||||
|
* Copyright (c) 2023 Vendicated and Vencord contributors
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Based on https://github.com/gergof/electron-builder-sandbox-fix/blob/master/lib/index.js
|
||||||
|
|
||||||
|
const fs = require("fs/promises");
|
||||||
|
const path = require("path");
|
||||||
|
|
||||||
|
const log = (message, dotFormatting = chalk.blue) => {
|
||||||
|
console.log(` ${dotFormatting("•")} ${message}`);
|
||||||
|
};
|
||||||
|
|
||||||
|
const afterPackHook = async params => {
|
||||||
|
if (process.platform !== "linux") {
|
||||||
|
// this fix is only required on linux
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const executable = path.join(params.appOutDir, params.packager.executableName);
|
||||||
|
|
||||||
|
const loaderScript = `#!/usr/bin/env bash
|
||||||
|
SCRIPT_DIR="$( cd "$( dirname "\${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
|
IS_STEAMOS=0
|
||||||
|
|
||||||
|
if [[ "$SteamOS" == "1" && "$SteamGamepadUI" == "1" ]]; then
|
||||||
|
echo "Running Vesktop on SteamOS, disabling sandbox"
|
||||||
|
IS_STEAMOS=1
|
||||||
|
fi
|
||||||
|
|
||||||
|
exec "$SCRIPT_DIR/${params.packager.executableName}.bin" "$([ "$IS_STEAMOS" == 1 ] && echo '--no-sandbox')" "$@"
|
||||||
|
`;
|
||||||
|
|
||||||
|
try {
|
||||||
|
await fs.rename(executable, executable + ".bin");
|
||||||
|
await fs.writeFile(executable, loaderScript);
|
||||||
|
await fs.chmod(executable, 0o755);
|
||||||
|
} catch (e) {
|
||||||
|
console.error("failed to create loder for sandbox fix: " + e.message);
|
||||||
|
throw new Error("Failed to create loader for sandbox fix");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = afterPackHook;
|
Reference in a new issue