popcon: initial launch-sortorder modification app

pull/2720/head
Rob Pilling 2023-04-24 22:29:17 +01:00
parent df50a4dd7b
commit d4878be7fa
5 changed files with 72 additions and 0 deletions

View File

@ -0,0 +1 @@
0.01: New App!

View File

@ -0,0 +1,9 @@
Popcon
======
Display apps sorted by regular use.
Settings
--------
- `Show Clocks` - Whether clocks are shown in the app list. Default `Yes`.

BIN
apps/popconlaunch/app.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 899 B

43
apps/popconlaunch/boot.ts Normal file
View File

@ -0,0 +1,43 @@
// TODO: fastload
const oldRead = require("Storage").readJSON;
let cache;
const ensureCache = () => {
if(!cache){
cache = oldRead("popcon.cache.json", 1);
if(!cache)
cache = {};
}
};
const saveCache = () => {
require("Storage").writeJSON("popcon.cache.json", cache);
};
const sortCache = () => {
// TODO
};
require("Storage").readJSON = (fname, skipExceptions) => {
const j = oldRead(fname, skipExceptions);
if(fname.test(/\.info$/)){
ensureCache();
if(j.src && cache[j.src]?.sortorder)
j.sortorder = cache[j.src].sortorder;
}
return j;
} satisfies typeof oldRead;
const oldLoad = load;
load = (src) => {
ensureCache();
cache[src].pop++;
cache[src].last = Date.now();
sortCache();
saveCache();
return oldLoad(src);
};

View File

@ -0,0 +1,19 @@
{
"id": "popconlaunch",
"name": "Popcon Launcher",
"shortName": "Popcon",
"version": "0.01",
"description": "Launcher displaying your favourite (popular) apps first",
"readme": "README.md",
"icon": "TODO_app.png",
"type": "launch",
"tags": "tool,system,launcher",
"supports": ["BANGLEJS2"],
"storage": [
{"name":"popcon.boot.js","url":"boot.js"}
],
"data": [
{"name":"popcon.cache.json"}
],
"sortorder": -10
}