-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmain.js
58 lines (48 loc) · 1.28 KB
/
main.js
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
const { app, BrowserWindow, ipcMain } = require('electron');
const os = require('os');
const pty = require('node-pty');
var shell = os.platform() === 'win32' ? 'powershell.exe' : 'bash';
var shell = os.platform() === 'darwin' ? 'zsh' : 'zsh';
function createWindow() {
const win = new BrowserWindow({
Width: 370,
Height: 190,
frame: process.platform === 'darwin',
transparent: process.platform === 'darwin',
webPreferences: {
nodeIntegration: true,
navigateOnDragDrop: true,
enableRemoteModule: true,
},
icon: './icons/terminex-dark-circle.png',
});
win.removeMenu();
var ptyprocess = pty.spawn(shell, [], {
name: 'xterm-color',
cols: 100,
rows: 30,
cwd: process.env.HOME,
env: process.env,
});
ptyprocess.on('data', function (data) {
win.webContents.send('terminal.incData', data);
});
ipcMain.on('terminal.toTerm', function (event, data) {
ptyprocess.write(data);
});
win.loadFile('index.html');
}
app.whenReady().then(createWindow);
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit();
}
});
if (require('electron-squirrel-startup')) {
app.quit();
}
app.on('activate', () => {
if (BrowserWindow.getAllWindows().length === 0) {
createWindow();
}
});