Skip to content

add js app shortcuts#2227

Open
alexkotr1 wants to merge 3 commits intoBruceDevices:mainfrom
alexkotr1:main
Open

add js app shortcuts#2227
alexkotr1 wants to merge 3 commits intoBruceDevices:mainfrom
alexkotr1:main

Conversation

@alexkotr1
Copy link
Copy Markdown

@alexkotr1 alexkotr1 commented Feb 24, 2026

  • Proposed Changes
    Added a way to pin custom JS scripts directly to the main home screen. Instead of digging through the Scripts app every time you want to use a favorite tool, you can now just pin it to the main carousel.

When you select a script, instead of just running it immediately, it now opens a small submenu with:

Run App: Runs it normally.

Pin to Home: Copies the file to a new /apps folder on LittleFS.

Unpin from Home: (Shows up if it's already pinned) Removes it from the /apps folder.

Under the hood, I added a DynamicJSApp class in main_menu.cpp. It scans the /apps folder and dynamically generates menu items for whatever it finds there, injecting them straight into the main menu.
Types of Changes

[x] New Feature (non-breaking change which adds functionality)

[x] UI/UX Improvement

[ ] Bugfix (non-breaking change which fixes an issue)

[ ] Breaking Change (fix or feature that would cause existing functionality to not work as expected)
  • Verification

    Upload a .js file to /scripts via the WebUI.

    Open JS Interpreter on the device.

    Click your script and select Pin to Home.

    Back out to the main menu—you'll see your script right there in the carousel.

    Go back to JS Interpreter,click the same script, and hit Unpin from Home. Back out to the main menu and it's gone.

  • Testing

Tested manually on my board using LittleFS.

Verified that copying the files to and from /apps/ works cleanly.

@emericklaw
Copy link
Copy Markdown
Member

emericklaw commented Feb 24, 2026

Nice PR!

The main script folder is being standardised with the App Store being finalised.

It would be better to use this to get the main JS script path since all App Store apps will install into /BruceJS/<category>/<scriptname>.js:

String getScriptsFolder(FS *&fs) {
String folder;
String possibleFolders[] = {
"/BruceJS",
"/BruceScripts",
"/scripts",
};
int listSize = sizeof(possibleFolders) / sizeof(possibleFolders[0]);
for (int i = 0; i < listSize; i++) {
if (SD.exists(possibleFolders[i])) {
fs = &SD;
return possibleFolders[i];
}
if (LittleFS.exists(possibleFolders[i])) {
fs = &LittleFS;
return possibleFolders[i];
}
}
return "";
}

@JustablockCode
Copy link
Copy Markdown
Contributor

1770099407974

@emericklaw
Copy link
Copy Markdown
Member

Rather than adding them via the JS Interpreter script menu (and adding an extra button press when launching non-pinned apps) it would better placed implmenting like the setStartupApp() within the Config menu.

firmware/src/core/settings.cpp

Lines 1202 to 1228 in 58d9664

void setStartupApp() {
int idx = 0;
if (bruceConfig.startupApp == "") idx = 0;
options = {
{"None", [=]() { bruceConfig.setStartupApp(""); }, bruceConfig.startupApp == ""}
};
int index = 0;
for (String appName : startupApp.getAppNames()) {
index++;
if (bruceConfig.startupApp == appName) idx = index;
options.push_back({appName.c_str(), [=]() {
bruceConfig.setStartupApp(appName);
#if !defined(LITE_VERSION) && !defined(DISABLE_INTERPRETER)
if (appName == "JS Interpreter") {
options = getScriptsOptionsList("", true);
loopOptions(options, MENU_TYPE_SUBMENU, "Startup Script");
}
#endif
}});
}
loopOptions(options, idx);
options.clear();
}

@alexkotr1
Copy link
Copy Markdown
Author

@emericklaw added your suggested changes and moved the dynamicjs class in /modules

@bmorcelli
Copy link
Copy Markdown
Member

I believe that these files:

src/modules/dynamicjs/dynamicjs.cpp
src/modules/dynamicjs/dynamicjs.h

should be placed at: src/core/menu_items folder

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants