-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathlinuxscript.js
More file actions
72 lines (67 loc) · 2.24 KB
/
Copy pathlinuxscript.js
File metadata and controls
72 lines (67 loc) · 2.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
const { execSync } = require("child_process");
const fs = require("fs");
const path = require("path");
const os = require("os");
function fixChromeSandbox() {
if (process.env.APPIMAGE) {
console.log("ℹ️ AppImage ortamı: chrome-sandbox ayarı gereksiz, atlanıyor.");
return;
}
try {
const chromeSandboxPath = path.join(__dirname, "node_modules/electron/dist/chrome-sandbox");
if (fs.existsSync(chromeSandboxPath)) {
console.log("🔧 chrome-sandbox izni ayarlanıyor...");
execSync(`sudo chown root "${chromeSandboxPath}"`);
execSync(`sudo chmod 4755 "${chromeSandboxPath}"`);
console.log("✅ chrome-sandbox hazır.");
} else {
console.warn("⚠️ chrome-sandbox bulunamadı.");
}
} catch (error) {
console.error("🚫 chrome-sandbox ayarlanırken hata:", error.message);
}
}
function ensureShmExists() {
try {
const shmStat = fs.statSync("/dev/shm");
if (!shmStat.isDirectory()) {
throw new Error("/dev/shm is not a directory");
}
} catch (err) {
try {
console.log("⚠️ /dev/shm yok, oluşturuluyor...");
execSync("sudo mkdir -p /dev/shm && sudo chmod 1777 /dev/shm");
console.log("✅ /dev/shm başarıyla oluşturuldu.");
} catch (e) {
console.error("🚫 /dev/shm oluşturulamadı:", e.message);
}
}
}
function registerProtocol() {
const desktopPath = path.join(os.homedir(), ".local/share/applications/topluyo.desktop");
const appPath = process.env.APPIMAGE || process.execPath;
const desktopEntry = `[Desktop Entry]
Name=Topluyo
Exec=sh -c '"${appPath}" --no-sandbox %u'
Type=Application
Terminal=false
MimeType=x-scheme-handler/topluyo;
Categories=Network;Chat;
NoDisplay=false
StartupWMClass=Topluyo
`;
try {
fs.writeFileSync(desktopPath, desktopEntry, { mode: 0o755 });
execSync(`chmod +x "${desktopPath}"`);
execSync(`xdg-mime default topluyo.desktop x-scheme-handler/topluyo`);
execSync(`update-desktop-database ~/.local/share/applications`);
console.log("✅ topluyo:// protokolü başarıyla kaydedildi.");
} catch (err) {
console.error("🚫 Protokol kaydı başarısız:", err.message);
}
}
if (process.platform === "linux") {
fixChromeSandbox();
registerProtocol();
ensureShmExists();
}