Skip to content

Commit

Permalink
launcher: gracefully fail on missing icons.
Browse files Browse the repository at this point in the history
  • Loading branch information
Gadgetoid committed Mar 27, 2024
1 parent 50657d6 commit 01e04c3
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions badger_os/launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,13 @@ def render():
icon_label = label.replace("_", "-")
icon = f"{APP_DIR}/icon-{icon_label}"
label = label.replace("_", " ")
try:
png.open_file(f"{icon}.png")
png.decode(x - 26, 30)
except (OSError, RuntimeError):
jpeg.open_file(f"{icon}.jpg")
jpeg.decode(x - 26, 30)
for lib, ext in [(png, "png"), (jpeg, "jpg")]:
try:
lib.open_file(f"{icon}.{ext}")
lib.decode(x - 26, 30)
break
except (OSError, RuntimeError):
continue
display.set_pen(0)
w = display.measure_text(label, FONT_SIZE)
display.text(label, int(x - (w / 2)), 16 + 80, WIDTH, FONT_SIZE)
Expand Down

0 comments on commit 01e04c3

Please sign in to comment.