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
|
#!/usr/bin/@ELECTRON@
const name = 'deezer-enhanced';
const {app} = require('electron');
const fs = require('fs');
const path = require('path');
// 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 = path.join(path.dirname(__dirname), 'lib', name);
const packageJson = require(path.join(appPath, 'package.json'));
const productName = packageJson.name;
app.setAppPath(appPath);
app.setDesktopName(name + '.desktop');
app.setName(productName);
app.setPath('userCache', path.join(app.getPath('cache'), productName));
app.setPath('userData', path.join(app.getPath('appData'), productName));
app.setVersion(packageJson.version);
// Copy icon to userpath
try {
if (!fs.existsSync(path.join(app.getPath('userData'), 'assets', 'icon.png'))) {
fs.mkdirSync(path.join(app.getPath('userData'), 'assets'));
fs.copyFileSync(path.join(appPath, 'assets', 'icon.png'), path.join(app.getPath('userData'), 'assets', 'icon.png'));
}
} catch(err) {
console.log("Tray won't work: ");
console.log(err);
}
// Run the application
require('module')._load(appPath, module, true);
|