ref: use display status callback
This commit is contained in:
+3
-2
@@ -112,8 +112,9 @@ const init = async () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Check for display changes
|
// Check for display changes
|
||||||
interval(update, 1000);
|
setDisplayStatus("ON", () => {
|
||||||
setDisplayStatus("ON");
|
interval(update, 1000);
|
||||||
|
});
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|||||||
+58
-50
@@ -206,13 +206,14 @@ 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) {
|
||||||
console.log(`Progress: ${progress}%`);
|
console.log(`Progress: ${progress}%`);
|
||||||
}
|
}
|
||||||
updateApp(progress);
|
updateApp(progress);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -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,30 +339,32 @@ 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);
|
||||||
switch (status) {
|
hardware.setDisplayStatus("ON", () => {
|
||||||
case "Framed":
|
switch (status) {
|
||||||
WEBVIEW.window.restore();
|
case "Framed":
|
||||||
WEBVIEW.window.unmaximize();
|
WEBVIEW.window.restore();
|
||||||
WEBVIEW.window.setFullScreen(false);
|
WEBVIEW.window.unmaximize();
|
||||||
break;
|
WEBVIEW.window.setFullScreen(false);
|
||||||
case "Fullscreen":
|
break;
|
||||||
WEBVIEW.window.restore();
|
case "Fullscreen":
|
||||||
WEBVIEW.window.unmaximize();
|
WEBVIEW.window.restore();
|
||||||
WEBVIEW.window.setFullScreen(true);
|
WEBVIEW.window.unmaximize();
|
||||||
break;
|
WEBVIEW.window.setFullScreen(true);
|
||||||
case "Maximized":
|
break;
|
||||||
WEBVIEW.window.restore();
|
case "Maximized":
|
||||||
WEBVIEW.window.setFullScreen(false);
|
WEBVIEW.window.restore();
|
||||||
WEBVIEW.window.maximize();
|
WEBVIEW.window.setFullScreen(false);
|
||||||
break;
|
WEBVIEW.window.maximize();
|
||||||
case "Minimized":
|
break;
|
||||||
WEBVIEW.window.restore();
|
case "Minimized":
|
||||||
WEBVIEW.window.setFullScreen(false);
|
WEBVIEW.window.restore();
|
||||||
WEBVIEW.window.minimize();
|
WEBVIEW.window.setFullScreen(false);
|
||||||
break;
|
WEBVIEW.window.minimize();
|
||||||
case "Terminated":
|
break;
|
||||||
app.quit();
|
case "Terminated":
|
||||||
}
|
app.quit();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.subscribe(config.command_topic);
|
.subscribe(config.command_topic);
|
||||||
@@ -455,19 +461,21 @@ 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();
|
||||||
WEBVIEW.window.unmaximize();
|
WEBVIEW.window.unmaximize();
|
||||||
WEBVIEW.window.setFullScreen(true);
|
WEBVIEW.window.setFullScreen(true);
|
||||||
break;
|
break;
|
||||||
case "ON":
|
case "ON":
|
||||||
WEBVIEW.window.restore();
|
WEBVIEW.window.restore();
|
||||||
WEBVIEW.window.setFullScreen(false);
|
WEBVIEW.window.setFullScreen(false);
|
||||||
WEBVIEW.window.maximize();
|
WEBVIEW.window.maximize();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
hardware.setKeyboardVisibility(status);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.subscribe(config.command_topic);
|
.subscribe(config.command_topic);
|
||||||
|
|||||||
Reference in New Issue
Block a user