Skip to content

LordOS — a free, fast and secure GNU/Linux distribution based on Debian, with its own desktop environment: display server and Wayland compositor in C, a React UI engine on QuickJS, and private native apps.

Remote desktop: the first click or key in the session turns the sound on (browsers start it muted and the sound button hides in the top bar), unless the viewer already chose with the button

Federico Pereira079a77cd587f
diff --git a/docs/REMOTE.md b/docs/REMOTE.md
index b456e0f..6628d8d 100644
--- a/docs/REMOTE.md
+++ b/docs/REMOTE.md
@@ -574,7 +574,8 @@ The session's sound reaches the browser with the video (see [Video (WebRTC)](#vi
session's `lord-server` records the monitor of the default output from PipeWire itself (the same
`maudio.c` stream as the screen recorder's microphone, `@DEFAULT_MONITOR@`, mono 48 kHz) into a
shared-memory ring, and the live encoder makes Opus of it (20 ms frames, 64 kbit/s, low delay). The
-page starts muted (browsers only play sound after a click) and has a sound button in its top bar.
+page starts muted (browsers only play sound after a click): the first click or key in the session
+turns it on, unless the viewer already chose with the sound button in its top bar.
Still to do: stereo, and the microphone the other way (by permission).
## Remote login (SSH)
diff --git a/server/src/remote/client.html b/server/src/remote/client.html
index 794eefa..92a5e60 100644
--- a/server/src/remote/client.html
+++ b/server/src/remote/client.html
@@ -390,12 +390,19 @@ function onTile(d) {
queue = queue.then(() => { for (const [x, y, w, h] of r) ctx.clearRect(x, y, w, h); });
}
}
-$('snd').onclick = () => {
- vid.muted = !vid.muted;
- if (!vid.muted) vid.play().catch(() => {});
+function setSound(on) {
+ vid.muted = !on;
+ if (on) vid.play().catch(() => {});
$('snd').textContent = vid.muted ? '🔇' : '🔊';
$('snd').title = vid.muted ? T.sndOn : T.sndOff;
-};
+}
+// browsers only play sound after a gesture: the first click or key in the session turns it on, unless
+// the viewer already chose with the button (hidden in the top bar)
+let soundChosen = false;
+$('snd').onclick = () => { soundChosen = true; setSound(vid.muted); };
+const soundOnGesture = () => { if (!soundChosen && vid.muted && !$('snd').hidden) { soundChosen = true; setSound(true); } };
+$('c').addEventListener('pointerdown', soundOnGesture);
+$('c').addEventListener('keydown', soundOnGesture);
// ---- the WebSocket: sign-in, signaling, cursor, clipboard. Reconnects with backoff, without a new
// sign-in while the cookie lasts; if the cookie is gone, /desk sends the browser to the sign-in page ----