You would need to include a storage method for the text to be retrieved from in Scriptable. When the widget loads on Home Screen, it runs the code again and also at various intervals unless otherwise specified
Thanks for the hint, I save the text now to a file and it works.
In case someone finds this, this is how I do it.
let fm = FileManager.local();
let directory = fm.documentsDirectory();
let filePath = fm.joinPath(directory, "varianza.txt");
var content, w;
w = new ListWidget();
if (!fm.fileExists(filePath)) {
fm.writeString(filePath, "New file created");
} else if (args.plainTexts.length > 0) {
fm.writeString(filePath, args.plainTexts[0]);
}
w.addText(fm.readString(filePath));
Script.setWidget(w);
Script.complete();
I still need to open the app or call the refresh widget shortcut that opens the app, but better than nothing.
If someone know a way to trigger the refresh without opening the app let me know!
You’re welcome! Are you updating that file via a shortcut? The widget will refresh after the refresh time (variable by default) has elapsed and you are looking at the widget. This can be anywhere from 5-20 minutes from what I’ve seen.