Skip to content

Instantly share code, notes, and snippets.

@rozek
Created January 13, 2020 10:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rozek/24f7824c601019ec867b6ed78d03620f to your computer and use it in GitHub Desktop.
Save rozek/24f7824c601019ec867b6ed78d03620f to your computer and use it in GitHub Desktop.
Bangle.js: prints a list of all installed clocks
const Storage = require('Storage');
let ClockList = [];
let FileList = Storage.list();
for (let i = 0, l = FileList.length; i < l; i++) {
let FileName = FileList[i];
if (FileName[0] === '+') {
try {
let AppType = Storage.readJSON(FileName)['type'];
if (AppType === 'clock') {
ClockList.push(FileName.slice(1));
}
} catch (Signal) { /* nop */ }
}
}
ClockList.sort();
print('list of installed clocks:');
for (let i = 0, l = ClockList.length; i < l; i++) {
print(' -',ClockList[i].replace(/[\x00-\x1F\x7F-\x9F]/g, function (Match) {
let CharCode = Match.charCodeAt(0);
return '\\x' + (CharCode < 10 ? '0' : '') + CharCode.toString(16);
}));
}
print('done');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment