Skip to content
Snippets Groups Projects
Commit 8a1cf867 authored by rahix's avatar rahix
Browse files

feat(menu): List special apps at the top


Add a mechanism for "favorite apps" which are shown at the top of the
app-list no matter what.

Signed-off-by: default avatarRahix <rahix@rahix.de>
parent 3445a353
No related branches found
No related tags found
No related merge requests found
......@@ -16,21 +16,30 @@ import utime
App = collections.namedtuple("App", ["name", "path"])
# Favorite apps which are shown at the very top of the app list
FAVORITE_APPS = ["personal_state", "ecg"]
def enumerate_entries():
for f in os.listdir("/"):
if f == "main.py":
yield App("Home", f)
yield from enumerate_apps(FAVORITE_APPS)
yield from sorted(enumerate_apps(), key=lambda b: b.name.lower())
def enumerate_apps():
def enumerate_apps(apps=None):
"""List all installed apps."""
for app in os.listdir("/apps"):
for app in apps or os.listdir("/apps"):
if app.startswith("."):
continue
# Skip special apps when enumerating from filesystem
if apps is None and app in FAVORITE_APPS:
continue
if app.endswith(".py") or app.endswith(".elf"):
yield App(app, "/apps/" + app)
continue
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment