Skip to content

Commit 4ab637b

Browse files
author
Kiosk
committed
feat: show WiFi SSID / Ethernet status in kiosk, click opens WiFi Manager
1 parent 8619d12 commit 4ab637b

2 files changed

Lines changed: 33 additions & 3 deletions

File tree

screen.html

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,10 +149,11 @@
149149
.qr-url { color: #4a9eff; font-family: monospace; margin-top: 8px; word-break: break-all; text-decoration: none; transition: color 0.2s; display: block; text-align: center; line-height: 1.3; }
150150
.qr-url:hover { color: #7bc0ff; text-decoration: underline; }
151151

152-
.status { position: fixed; bottom: max(8px, 1.5vh); right: max(8px, 1.5vw); padding: max(4px, 0.8vmin) max(8px, 1.5vmin); border-radius: max(3px, 0.5vmin); font-size: max(10px, min(2vw, 2vh, 14px)); z-index: 1001; transition: opacity 0.3s, visibility 0.3s; opacity: 0.7; }
152+
.status { position: fixed; bottom: max(8px, 1.5vh); right: max(8px, 1.5vw); padding: max(4px, 0.8vmin) max(8px, 1.5vmin); border-radius: max(3px, 0.5vmin); font-size: max(10px, min(2vw, 2vh, 14px)); z-index: 1001; transition: opacity 0.3s, visibility 0.3s; opacity: 0.7; cursor: pointer; }
153153
.status.hidden { opacity: 0; visibility: hidden; }
154154
.status.connecting { background: #FF9800; color: #000; }
155155
.status.connected { background: #4CAF50; color: #fff; }
156+
.status.disconnected { background: #666; color: #fff; }
156157
.status.error { background: #f44336; color: #fff; }
157158

158159
#audioMutedIndicator { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: rgba(0, 0, 0, 0.9); color: white; padding: 12px 24px; border-radius: 8px; font-size: 16px; z-index: 3000; cursor: pointer; display: none; align-items: center; gap: 10px; border: 1px solid rgba(255, 255, 255, 0.2); }
@@ -340,6 +341,24 @@
340341
el.textContent = text;
341342
}
342343

344+
// Network status: poll connection info and display WiFi SSID / Ethernet / Disconnected
345+
let _networkPollInterval = null;
346+
function updateNetworkStatus() {
347+
fetch('/api/network-info').then(r => r.json()).then(info => {
348+
const conn = info.connection;
349+
if (conn?.type === 'wifi') updateStatus('connected', '📶 ' + conn.name);
350+
else if (conn?.type === 'ethernet') updateStatus('connected', '🔌 Ethernet');
351+
else updateStatus('disconnected', '⚠ No Internet');
352+
}).catch(() => updateStatus('disconnected', '⚠ No Internet'));
353+
}
354+
// Poll network status every 10s to catch changes
355+
_networkPollInterval = setInterval(updateNetworkStatus, 10000);
356+
357+
// Click status label → open WiFi Manager
358+
document.getElementById('status').addEventListener('click', () => {
359+
window.location.href = 'http://' + window.location.hostname + ':3457';
360+
});
361+
343362
function connectWebSocket() {
344363
updateStatus('connecting', 'Connecting...');
345364
wsManager = new WebSocketManager({
@@ -364,7 +383,7 @@
364383
switch (msg.type) {
365384
case 'registered':
366385
console.log('Screen registered:', msg.screenId);
367-
updateStatus('connected', 'Ready: ' + screenId);
386+
updateNetworkStatus();
368387
break;
369388

370389
case 'controller-connected':

server.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,18 @@ const serverConfig = {
368368
}
369369

370370
if (pathname === "/api/network-info") {
371-
return new Response(JSON.stringify({ ip: LOCAL_IP, port: PORT, url: LOCAL_IP ? `http://${LOCAL_IP}:${PORT}` : null }),
371+
// Include active connection info (WiFi SSID or Ethernet)
372+
let connection = { type: "unknown", name: "" };
373+
try {
374+
const result = Bun.spawnSync({ cmd: ["nmcli", "-t", "-f", "NAME,TYPE,DEVICE", "connection", "show", "--active"] });
375+
const lines = result.stdout.toString().trim().split("\n");
376+
for (const line of lines) {
377+
const [name, type, device] = line.split(":");
378+
if (type === "802-11-wireless") { connection = { type: "wifi", name }; break; }
379+
if (type === "802-3-ethernet" && connection.type !== "wifi") { connection = { type: "ethernet", name: device || name }; }
380+
}
381+
} catch {}
382+
return new Response(JSON.stringify({ ip: LOCAL_IP, port: PORT, url: LOCAL_IP ? `http://${LOCAL_IP}:${PORT}` : null, connection }),
372383
{ headers: { "Content-Type": "application/json", ...getHeaders(req) } });
373384
}
374385

0 commit comments

Comments
 (0)