Add localhost screenshot endpoint and email-upload guide
- Electron main now exposes http://127.0.0.1:9990/screenshot that returns a PNG via CDP Page.captureScreenshot (GNOME Wayland blocks external capture, and webContents.capturePage() hangs on this compositor). The endpoint is localhost-only. - EMAIL_UPLOAD.md documents the n8n IMAP -> Samba share workflow for Skylight-style email-to-photo-frame uploads.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { app, BrowserWindow, ipcMain, screen, powerSaveBlocker } from 'electron';
|
||||
import * as path from 'path';
|
||||
import * as fs from 'fs';
|
||||
import * as http from 'http';
|
||||
import { ScreenManager } from './services/ScreenManager';
|
||||
import { PresenceDetector } from './services/PresenceDetector';
|
||||
import { FrigateStreamer } from './services/FrigateStreamer';
|
||||
@@ -230,6 +231,34 @@ app.on('window-all-closed', () => {
|
||||
}
|
||||
});
|
||||
|
||||
// Localhost-only HTTP endpoint for self-screenshots. GNOME Wayland blocks
|
||||
// external screen capture, but webContents.capturePage() works from inside.
|
||||
// Usage: curl -s http://127.0.0.1:9990/screenshot > out.png
|
||||
http
|
||||
.createServer(async (req, res) => {
|
||||
if (req.url === '/screenshot' && mainWindow) {
|
||||
try {
|
||||
const wc = mainWindow.webContents;
|
||||
if (!wc.debugger.isAttached()) wc.debugger.attach('1.3');
|
||||
const result = (await wc.debugger.sendCommand('Page.captureScreenshot', {
|
||||
format: 'png',
|
||||
captureBeyondViewport: false,
|
||||
})) as { data: string };
|
||||
res.setHeader('Content-Type', 'image/png');
|
||||
res.end(Buffer.from(result.data, 'base64'));
|
||||
} catch (err) {
|
||||
res.statusCode = 500;
|
||||
res.end(String(err));
|
||||
}
|
||||
} else {
|
||||
res.statusCode = 404;
|
||||
res.end();
|
||||
}
|
||||
})
|
||||
.listen(9990, '127.0.0.1', () => {
|
||||
console.log('Screenshot endpoint on http://127.0.0.1:9990/screenshot');
|
||||
});
|
||||
|
||||
// Handle uncaught exceptions
|
||||
process.on('uncaughtException', (error) => {
|
||||
console.error('Uncaught exception:', error);
|
||||
|
||||
Reference in New Issue
Block a user