Skip to content

Commit 08e0343

Browse files
committed
Add config disable_screensaver_on_browser_mod_popup
1 parent 2d704ab commit 08e0343

File tree

1 file changed

+27
-7
lines changed

1 file changed

+27
-7
lines changed

wallpanel.js

+27-7
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ class ScreenWakeLock {
107107
}
108108
}
109109

110-
const version = "4.28.0";
110+
const version = "4.29.0";
111111
const defaultConfig = {
112112
enabled: false,
113113
enabled_on_tabs: [],
@@ -131,6 +131,7 @@ const defaultConfig = {
131131
stop_screensaver_on_mouse_click: true,
132132
stop_screensaver_on_key_down: true,
133133
stop_screensaver_on_location_change: true,
134+
disable_screensaver_on_browser_mod_popup: false,
134135
show_images: true,
135136
image_url: "https://picsum.photos/${width}/${height}?random=${timestamp}",
136137
immich_api_key: "",
@@ -225,6 +226,17 @@ if (window.browser_mod) {
225226
}
226227
}
227228

229+
function getActiveBrowserModPopup() {
230+
if (!browserId) {
231+
return null;
232+
}
233+
const bmp = document.getElementsByTagName("browser-mod-popup");
234+
if (!bmp || !bmp[0] || !bmp[0].shadowRoot || bmp[0].shadowRoot.children.length == 0) {
235+
return null;
236+
}
237+
return bmp[0];
238+
}
239+
228240
function isObject(item) {
229241
return (item && typeof item === 'object' && !Array.isArray(item));
230242
}
@@ -449,6 +461,9 @@ function isActive() {
449461
if (config.enabled_on_tabs && config.enabled_on_tabs.length > 0 && activeTab && !config.enabled_on_tabs.includes(activeTab)) {
450462
return false;
451463
}
464+
if (config.disable_screensaver_on_browser_mod_popup && getActiveBrowserModPopup()) {
465+
return false;
466+
}
452467
return true;
453468
}
454469

@@ -778,9 +793,14 @@ class WallpanelView extends HuiView {
778793
return;
779794
}
780795
if (this.screensaverRunning()) {
781-
this.updateScreensaver();
796+
if (config.disable_screensaver_on_browser_mod_popup && getActiveBrowserModPopup()) {
797+
this.stopScreensaver();
798+
}
799+
else {
800+
this.updateScreensaver();
801+
}
782802
}
783-
else {
803+
else if (isActive()) {
784804
if (config.idle_time > 0 && Date.now() - this.idleSince >= config.idle_time*1000) {
785805
this.startScreensaver();
786806
}
@@ -2474,13 +2494,13 @@ class WallpanelView extends HuiView {
24742494
return;
24752495
}
24762496

2477-
const bmp = document.getElementsByTagName("browser-mod-popup");
2478-
if (bmp && bmp[0] && bmp[0].shadowRoot) {
2479-
const bm_elements = [ bmp[0].shadowRoot.querySelector(".content"), bmp[0].shadowRoot.querySelector("ha-dialog-header") ];
2497+
const bmp = getActiveBrowserModPopup();
2498+
if (bmp) {
2499+
const bm_elements = [ bmp.shadowRoot.querySelector(".content"), bmp.shadowRoot.querySelector("ha-dialog-header") ];
24802500
for (let i=0; i<bm_elements.length; i++) {
24812501
if (bm_elements[i]) {
24822502
const pos = bm_elements[i].getBoundingClientRect();
2483-
logger.debug("Event position:", elements[i], x, y, pos.left, pos.right, pos.top, pos.bottom);
2503+
logger.debug("Event position:", bm_elements[i], x, y, pos.left, pos.right, pos.top, pos.bottom);
24842504
if (x >= pos.left && x <= pos.right && y >= pos.top && y <= pos.bottom) {
24852505
logger.debug("Event on browser mod popup:", bm_elements[i]);
24862506
return;

0 commit comments

Comments
 (0)