aboutsummaryrefslogtreecommitdiffstats
path: root/static/app.js
diff options
context:
space:
mode:
Diffstat (limited to 'static/app.js')
-rw-r--r--static/app.js14
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();