diff options
| author | Danilo M. <danix@danix.xyz> | 2026-11-10 10:33:00 +0100 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-11-10 10:33:00 +0100 |
| commit | 213a82118a7f5db58759edffe8d1776475e4e4e4 (patch) | |
| tree | 901a9f7803e3be1ba361228223fe6321c9d655cc /static/app.js | |
| parent | fa71508066128124feb1b1110ca8e8f65e831508 (diff) | |
| download | deck-it-213a82118a7f5db58759edffe8d1776475e4e4e4.tar.gz deck-it-213a82118a7f5db58759edffe8d1776475e4e4e4.zip | |
feat: keep the tablet awake while the dashboard is shown
The page takes a Screen Wake Lock while visible and again whenever it
comes back to the front, so the tablet neither dims nor starts its
screensaver over the dashboard. It changes no tablet setting, and the
screen goes back to its own timeout when the page is hidden. 127.0.0.1
is a secure context, which the API requires.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'static/app.js')
| -rw-r--r-- | static/app.js | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/static/app.js b/static/app.js index e2da02a..4c562ff 100644 --- a/static/app.js +++ b/static/app.js @@ -252,8 +252,22 @@ refreshers.push(refreshTheme); refreshTheme(); setInterval(refreshTheme, 5000); +// Keep the tablet's screen on while the dashboard is in front, so it never +// dims or starts its screensaver. The lock drops whenever the page is hidden +// and is taken again when it comes back. 127.0.0.1 is a secure context, which +// the Wake Lock API requires. +async function keepAwake() { + try { + if (document.visibilityState === "visible") await navigator.wakeLock?.request("screen"); + } catch { + // refused (battery saver): the screen just follows its own timeout + } +} +keepAwake(); + document.addEventListener("visibilitychange", () => { if (document.visibilityState === "visible") refreshers.forEach((fn) => fn()); + keepAwake(); }); boot(); |
