From 94fe988b0854a180fe732cdf9b56149dd7d38596 Mon Sep 17 00:00:00 2001 From: Richard de Boer Date: Sun, 25 Apr 2021 15:11:26 +0200 Subject: [PATCH] gbmusic: only auto-start from clock apps --- apps/gbmusic/ChangeLog | 3 ++- apps/gbmusic/app.js | 2 +- apps/gbmusic/widget.js | 6 ++++++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/apps/gbmusic/ChangeLog b/apps/gbmusic/ChangeLog index 4fa99c934..f456a4b16 100644 --- a/apps/gbmusic/ChangeLog +++ b/apps/gbmusic/ChangeLog @@ -1,2 +1,3 @@ 0.01: Initial version -0.02: Increase text brightness, improve controls, (try to) reduce memory usage \ No newline at end of file +0.02: Increase text brightness, improve controls, (try to) reduce memory usage +0.03: Only auto-start if active app is a clock \ No newline at end of file diff --git a/apps/gbmusic/app.js b/apps/gbmusic/app.js index 7cfbb574a..d54f449b1 100644 --- a/apps/gbmusic/app.js +++ b/apps/gbmusic/app.js @@ -538,7 +538,7 @@ function startLCDWatch() { ///////////////////// // check for saved music stat (by widget) to load g.clear(); -global.gbmusic_active = true; // we don't need our widget +global.gbmusic_active = true; // we don't need our widget (needed for <2.09 devices) Bangle.loadWidgets(); Bangle.drawWidgets(); delete (global.gbmusic_active); diff --git a/apps/gbmusic/widget.js b/apps/gbmusic/widget.js index 1a55490b5..1015822c8 100644 --- a/apps/gbmusic/widget.js +++ b/apps/gbmusic/widget.js @@ -2,6 +2,12 @@ if (global.gbmusic_active || !(require("Storage").readJSON("gbmusic.json", 1) || {}).autoStart) { return } + if (typeof __FILE__ === 'string') { // only exists since 2v09 + const info = require("Storage").readJSON(__FILE__.split(".")[0]+".info", 1) || false; + if (info && info.type!=="clock") { // info can have no type (but then it isn't a clock) + return; + } + } let state, info function checkMusic() {