summarylogtreecommitdiffstats
path: root/atom.js
blob: c3efd46e391e1098bb909149cd0363442cb0ed42 (plain)
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
#!/usr/bin/electron5

const name = "atom";

const {app} = require("electron");
const fs = require("fs");
const Module = require("module");
const {join} = require("path");
const vm = require("vm");

// Change command name.
const fd = fs.openSync("/proc/self/comm", fs.constants.O_WRONLY);
fs.writeSync(fd, name);
fs.closeSync(fd);

// Remove first command line argument (/usr/bin/electron).
process.argv.splice(0, 1);

// Set application paths.
const appPath = __dirname;
const packageJson = require(join(appPath, "package.json"));
const productName = packageJson.productName;
app.setAppPath(appPath);
app.setDesktopName(name + ".desktop");
app.setName(productName);
app.setPath("userCache", join(app.getPath("cache"), productName));
app.setPath("userData", join(app.getPath("appData"), productName));
app.setVersion(packageJson.version);

// Run the application.
const startupJs = fs.readFileSync(join(appPath, "startup.js"), "utf-8");
vm.runInThisContext(startupJs);
Module._load(appPath, Module, true);