Skip to content

Commit

Permalink
Merge pull request #6 from olzzon/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
olzzon authored Feb 17, 2024
2 parents 9ea5335 + cd6eecd commit 6ce75a4
Show file tree
Hide file tree
Showing 7 changed files with 1,456 additions and 1,188 deletions.
4 changes: 1 addition & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: 16.x
node-version: 18.x

- name: Install dependencies
run: yarn install
Expand Down Expand Up @@ -55,8 +55,6 @@ jobs:
release_name: Release ${{ github.ref }}
draft: false
prerelease: false
run: |
zip --junk-paths ninja-player README.md
- name: Upload Assets
id: upload_asset
uses: actions/upload-release-asset@v1
Expand Down
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,27 @@ There's a build in webserver that serves a webpage with links to the videostream
<img src='./docs/getlinkpage.png' width='600px' />


### Mac OS X - setup:

## Cron job that runs forcequit.sh at 4am
```
export EDITOR=nano
sudo crontab -e
```
Add this line:
```
0 4 * * * /bin/bash /path/to/file/forcequit.sh >/tmp/stdout.log 2>/tmp/stderr.log
```
(There's an example /docs/example scripts/forcequit.sh file in the repo)

To prevent apps from reopening after reboot, run this command:
```
defaults write -g ApplePersistence -bool no
```


## Auto start of Ninja Player at boot - delayed 30 sec (For webCam to load first)
Use the example in /docs/example scripts/delay-start.ninja.scpt



Binary file added docs/example scripts/delay-start-ninja.scpt
Binary file not shown.
25 changes: 25 additions & 0 deletions docs/example scripts/forcequit.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash

# Set the app name
app_name="ninja-player"

# Get the current time
current_time=$(date +%s)

# Set the desired time for the kill and reboot (4 am)
desired_time=$(date -j -f "%H:%M" "04:00" +%s)

# Calculate the time difference until the desired time
time_diff=$((desired_time - current_time))

# Sleep until the desired time (4 am)
sleep $time_diff

# Check if the app is running
if pgrep -xq "$app_name"; then
# Force kill the app
pkill -9 "$app_name"
fi

# Reboot the Mac
/sbin/shutdown -r now
46 changes: 23 additions & 23 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "ninja-player",
"productName": "ninja-player",
"version": "1.1.3",
"version": "1.1.4",
"description": "Video ingest to VDO.ninja",
"main": ".webpack/main",
"scripts": {
Expand Down Expand Up @@ -68,35 +68,35 @@
}
},
"devDependencies": {
"@electron-forge/cli": "^6.0.0-beta.65",
"@electron-forge/maker-deb": "^6.0.0-beta.65",
"@electron-forge/maker-rpm": "^6.0.0-beta.65",
"@electron-forge/maker-squirrel": "^6.0.0-beta.65",
"@electron-forge/maker-zip": "^6.0.0-beta.65",
"@electron-forge/plugin-webpack": "6.0.0-beta.65",
"@types/react": "^18.0.17",
"@types/react-dom": "^18.0.6",
"@types/request": "^2.48.8",
"@typescript-eslint/eslint-plugin": "^5.0.0",
"@typescript-eslint/parser": "^5.0.0",
"@electron-forge/cli": "^7.2.0",
"@electron-forge/maker-deb": "^7.2.0",
"@electron-forge/maker-rpm": "^7.2.0",
"@electron-forge/maker-squirrel": "^7.2.0",
"@electron-forge/maker-zip": "^7.2.0",
"@electron-forge/plugin-webpack": "^7.2.0",
"@types/react": "^18.2.56",
"@types/react-dom": "^18.2.19",
"@types/request": "^2.48.12",
"@typescript-eslint/eslint-plugin": "^7.0.1",
"@typescript-eslint/parser": "^7.0.1",
"@vercel/webpack-asset-relocator-loader": "1.7.3",
"css-loader": "^6.0.0",
"electron": "20.0.3",
"eslint": "^8.0.1",
"eslint-plugin-import": "^2.25.0",
"fork-ts-checker-webpack-plugin": "^7.2.1",
"css-loader": "^6.10.0",
"electron": "28.2.3",
"eslint": "^8.56.0",
"eslint-plugin-import": "^2.29.1",
"fork-ts-checker-webpack-plugin": "^9.0.2",
"node-loader": "^2.0.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"style-loader": "^3.0.0",
"ts-loader": "^9.2.2",
"typescript": "~4.5.4"
"style-loader": "^3.3.4",
"ts-loader": "^9.5.1",
"typescript": "~5.3.3"
},
"dependencies": {
"electron-squirrel-startup": "^1.0.0",
"express": "^4.18.1",
"express": "^4.18.2",
"request": "^2.88.2",
"socket.io": "^4.5.2",
"socket.io-client": "^4.5.2"
"socket.io": "^4.7.4",
"socket.io-client": "^4.7.4"
}
}
18 changes: 16 additions & 2 deletions src/server/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { app, BrowserWindow, ipcMain, Menu } from "electron";
import { app, BrowserWindow, ipcMain, Menu, powerMonitor } from "electron";
import { ISettings } from "../model/types";
import { expressHandler } from "./expressHandler";
import { loadSettings, saveSettings } from "./utils/storage";
Expand Down Expand Up @@ -55,6 +55,7 @@ const menu = Menu.buildFromTemplate([
},
{
label: "Quit",
accelerator: process.platform === 'darwin' ? 'Cmd+Q' : 'Alt+f4',
click() {
quitApp();
},
Expand Down Expand Up @@ -107,7 +108,7 @@ app.on("ready", createWindow);
// explicitly with Cmd + Q.
app.on("window-all-closed", () => {
if (process.platform !== "darwin") {
app.quit();
quitApp();
}
});

Expand All @@ -119,6 +120,15 @@ app.on("activate", () => {
}
});

app.on('quit', () => {
quitApp();
});

powerMonitor.on('shutdown', () => {
quitApp();
});


// In this file you can include the rest of your app's specific main process
// code. You can also put them in separate files and import them here.

Expand All @@ -137,5 +147,9 @@ ipcMain.handle("get-settings", async () => {
return settings;
});

ipcMain.on("quitApp", function() {
quitApp();
});

expressHandler(settings);

Loading

0 comments on commit 6ce75a4

Please sign in to comment.