From 13d17b25a6e34d4de4b1756504c91b97d9e5da0f Mon Sep 17 00:00:00 2001 From: Martin Boonk Date: Thu, 20 Oct 2022 19:24:06 +0200 Subject: [PATCH] setting - Adds setting for launcher --- apps/setting/settings.js | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/apps/setting/settings.js b/apps/setting/settings.js index 36af93a8a..d7b81fd59 100644 --- a/apps/setting/settings.js +++ b/apps/setting/settings.js @@ -87,6 +87,7 @@ function showSystemMenu() { /*LANG*/'LCD': ()=>showLCDMenu(), /*LANG*/'Locale': ()=>showLocaleMenu(), /*LANG*/'Select Clock': ()=>showClockMenu(), + /*LANG*/'Select Launcher': ()=>showLauncherMenu(), /*LANG*/'Date & Time': ()=>showSetTimeMenu() }; @@ -671,6 +672,35 @@ function showClockMenu() { } return E.showMenu(clockMenu); } +function showLauncherMenu() { + var launcherApps = require("Storage").list(/\.info$/) + .map(app => {var a=storage.readJSON(app, 1);return (a&&a.type == "launch")?a:undefined}) + .filter(app => app) // filter out any undefined apps + .sort((a, b) => a.sortorder - b.sortorder); + const launcherMenu = { + '': { + 'title': /*LANG*/'Select Launcher', + }, + '< Back': ()=>showSystemMenu(), + }; + launcherApps.forEach((app, index) => { + var label = app.name; + if ((!settings.launcher && index === 0) || (settings.launcher === app.src)) { + label = "* " + label; + } + launcherMenu[label] = () => { + if (settings.launcher !== app.src) { + settings.launcher = app.src; + updateSettings(); + showMainMenu(); + } + }; + }); + if (launcherApps.length === 0) { + launcherMenu[/*LANG*/"No Launchers Found"] = () => { }; + } + return E.showMenu(launcherMenu); +} function showSetTimeMenu() { d = new Date();