Skip to content

Commit b3fa479

Browse files
Add server run functionality
1 parent 72bcd38 commit b3fa479

File tree

6 files changed

+73
-16
lines changed

6 files changed

+73
-16
lines changed

build.sh

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/sh
2+
3+
4+
# If you run it in dev mode first with:
5+
# npm run start
6+
# Then the app tries to connect to localhost:3000 instead of packaging the actual files when building with:
7+
#./node_modules/.bin/electron-builder
8+
9+
# Therefore, first make sure the correct files are packaged with electron-forge like:
10+
./node_modules/.bin/electron-forge package
11+
12+
export DEBUG=electron-builder
13+
./node_modules/.bin/electron-builder -l appimage
14+
15+
# build more:
16+
#./node_modules/.bin/electron-builder -l appimage zip deb snap
17+
18+
# NOTE: Don't use prepackage because the electron-builder will not add the tigervnc/ folder:
19+
#./node_modules/.bin/electron-builder --prepackaged out/peerviewer-linux-x64/ -l appimage
20+

electron-builder.yml

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
appId: "com.peerviewer.app"
2+
"extraResources": [
3+
{
4+
"from": "tigervnc",
5+
"to": "tigervnc",
6+
"filter": ["**/*"]
7+
}
8+
]
9+

forge.config.js

+7-6
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,16 @@ module.exports = {
1010
},
1111
{
1212
name: '@electron-forge/maker-zip',
13-
platforms: ['darwin'],
13+
platforms: ['linux'],
1414
},
1515
{
1616
name: '@electron-forge/maker-deb',
17-
config: {},
18-
},
19-
{
20-
name: '@electron-forge/maker-rpm',
21-
config: {},
17+
config: {
18+
options: {
19+
maintainer: 'Thomas Farstrike',
20+
homepage: 'https://peerviewer.github.io/'
21+
}
22+
},
2223
},
2324
],
2425
plugins: [

package.json

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
2-
"name": "peerviewer",
3-
"productName": "peerviewer",
2+
"name": "PeerViewer",
3+
"productName": "PeerViewer",
44
"version": "1.0.0",
5-
"description": "My Electron application description",
5+
"description": "The peer-to-peer, completely free alternative to TeamViewer.",
66
"main": ".webpack/main",
77
"scripts": {
88
"start": "electron-forge start",
@@ -28,11 +28,11 @@
2828
"@vercel/webpack-asset-relocator-loader": "^1.7.3",
2929
"css-loader": "^6.8.1",
3030
"electron": "27.1.2",
31+
"electron-builder": "^24.9.1",
3132
"node-loader": "^2.0.0",
3233
"style-loader": "^3.3.3"
3334
},
3435
"dependencies": {
35-
"electron-squirrel-startup": "^1.0.0",
36-
"path-browserify": "^1.0.1"
36+
"electron-squirrel-startup": "^1.0.0"
3737
}
3838
}

src/main.js

+31-5
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
const { app, BrowserWindow, ipcMain } = require('electron');
2-
const { exec } = require('child_process');
3-
//const path = require('path');
2+
import { existsSync } from 'node:fs';
43

54
// Handle creating/removing shortcuts on Windows when installing/uninstalling.
6-
/*
75
if (require('electron-squirrel-startup')) {
86
app.quit();
97
}
10-
*/
118

129
const createWindow = () => {
1310
// Create the browser window.
@@ -50,11 +47,40 @@ app.on('activate', () => {
5047
}
5148
});
5249

50+
// Depending on how the app is launched, the tigervnc passwd file might be in different locations.
51+
function findPasswdFile() {
52+
//console.log(__dirname)
53+
//console.log(process.cwd())
54+
let defaultPath = 'tigervnc/passwd';
55+
let passwdfile = '';
56+
if (existsSync(defaultPath)) {
57+
console.log("Found it on first attempt!");
58+
passwdfile = defaultPath;
59+
} else {
60+
console.log("Can't find file here, trying another option...");
61+
// /tmp/.mount_peervizdlxvC/resources/app.asar/.webpack/main
62+
// becomes
63+
// /tmp/.mount_peervizdlxvC/resources
64+
const parts = __dirname.split('/');
65+
let prefix = parts.slice(0, -3).join('/');
66+
passwdfile = prefix + "/" + defaultPath;
67+
console.log("trying " + passwdfile);
68+
if (!existsSync(passwdfile)) {
69+
console.error("Could not find passwdfile!");
70+
}
71+
}
72+
73+
console.log("findPasswdFile returns " + passwdfile);
74+
return passwdfile;
75+
}
76+
5377
// Listen for the 'run-node-code' message from the renderer process
5478
ipcMain.on('run-server', (event) => {
5579
const { exec } = require('child_process');
5680

57-
exec('x0tigervncserver -PasswordFile tigervnc/passwd', (error, stdout, stderr) => {
81+
let passwdfile = findPasswdFile();
82+
83+
exec('x0tigervncserver -PasswordFile ' + passwdfile + ' ', (error, stdout, stderr) => {
5884
if (error) {
5985
console.error(`error: ${error.message}`);
6086
return;

tigervnc/passwd

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
@̩q����

0 commit comments

Comments
 (0)