ref: use display status callback

This commit is contained in:
leukipp
2025-09-09 17:25:56 +02:00
parent 10722fa217
commit 358fa3ca9c
2 changed files with 61 additions and 52 deletions
+2 -1
View File
@@ -112,8 +112,9 @@ const init = async () => {
}); });
// Check for display changes // Check for display changes
setDisplayStatus("ON", () => {
interval(update, 1000); interval(update, 1000);
setDisplayStatus("ON"); });
return true; return true;
}; };
+13 -5
View File
@@ -206,7 +206,7 @@ const initApp = () => {
.on("message", (topic, message) => { .on("message", (topic, message) => {
if (topic === config.command_topic) { if (topic === config.command_topic) {
console.log("Update App..."); console.log("Update App...");
hardware.setDisplayStatus("ON"); hardware.setDisplayStatus("ON", () => {
const args = ["-c", `bash <(wget -qO- ${APP.scripts.install}) update`]; const args = ["-c", `bash <(wget -qO- ${APP.scripts.install}) update`];
hardware.execScriptCommand("bash", args, (progress, error) => { hardware.execScriptCommand("bash", args, (progress, error) => {
if (progress) { if (progress) {
@@ -214,6 +214,7 @@ const initApp = () => {
} }
updateApp(progress); updateApp(progress);
}); });
});
} }
}) })
.subscribe(config.command_topic); .subscribe(config.command_topic);
@@ -259,8 +260,9 @@ const initShutdown = () => {
.on("message", (topic, message) => { .on("message", (topic, message) => {
if (topic === config.command_topic) { if (topic === config.command_topic) {
console.log("Shutdown system..."); console.log("Shutdown system...");
hardware.setDisplayStatus("ON"); hardware.setDisplayStatus("ON", () => {
hardware.shutdownSystem(); hardware.shutdownSystem();
});
} }
}) })
.subscribe(config.command_topic); .subscribe(config.command_topic);
@@ -285,8 +287,9 @@ const initReboot = () => {
.on("message", (topic, message) => { .on("message", (topic, message) => {
if (topic === config.command_topic) { if (topic === config.command_topic) {
console.log("Rebooting system..."); console.log("Rebooting system...");
hardware.setDisplayStatus("ON"); hardware.setDisplayStatus("ON", () => {
hardware.rebootSystem(); hardware.rebootSystem();
});
} }
}) })
.subscribe(config.command_topic); .subscribe(config.command_topic);
@@ -308,8 +311,9 @@ const initRefresh = () => {
.on("message", (topic, message) => { .on("message", (topic, message) => {
if (topic === config.command_topic) { if (topic === config.command_topic) {
console.log("Refreshing webview..."); console.log("Refreshing webview...");
hardware.setDisplayStatus("ON"); hardware.setDisplayStatus("ON", () => {
EVENTS.emit("reloadView"); EVENTS.emit("reloadView");
});
} }
}) })
.subscribe(config.command_topic); .subscribe(config.command_topic);
@@ -335,6 +339,7 @@ const initKiosk = () => {
if (topic === config.command_topic) { if (topic === config.command_topic) {
const status = message.toString(); const status = message.toString();
console.log("Set Kiosk Status:", status); console.log("Set Kiosk Status:", status);
hardware.setDisplayStatus("ON", () => {
switch (status) { switch (status) {
case "Framed": case "Framed":
WEBVIEW.window.restore(); WEBVIEW.window.restore();
@@ -359,6 +364,7 @@ const initKiosk = () => {
case "Terminated": case "Terminated":
app.quit(); app.quit();
} }
});
} }
}) })
.subscribe(config.command_topic); .subscribe(config.command_topic);
@@ -455,7 +461,7 @@ const initKeyboard = () => {
if (topic === config.command_topic) { if (topic === config.command_topic) {
const status = message.toString(); const status = message.toString();
console.log("Set Keyboard Visibility:", status); console.log("Set Keyboard Visibility:", status);
hardware.setKeyboardVisibility(status); hardware.setDisplayStatus("ON", () => {
switch (status) { switch (status) {
case "OFF": case "OFF":
WEBVIEW.window.restore(); WEBVIEW.window.restore();
@@ -468,6 +474,8 @@ const initKeyboard = () => {
WEBVIEW.window.maximize(); WEBVIEW.window.maximize();
break; break;
} }
hardware.setKeyboardVisibility(status);
});
} }
}) })
.subscribe(config.command_topic); .subscribe(config.command_topic);