A module to create illusions of transparent backgrounds for Scriptable widgets.
Features
- Interactive Configuration
- Dark and Light mode support
- Methods to get the actual background image or the image path
- Store widget positions
- Option for semi-transparent style
-
Download both no-background.js
-
Add the following code in your widget code
const nobg = importModule('no-background.js') const widget = new ListWidget() widget.backgroundImage = await nobg.getSliceForWidget(Script.name()) // the rest of your widget code
-
Run your widget!
The getSliceForWidget method has an optional second boolean argument to prompt for a new widget position. This is useful when you changed the position of the widget on your home screen.
const RESET_POSITION = true
const nobg = importModule('no-background,js')
const widget = new ListWidget()
widget.backgroundImage = await nobg.getSliceForWidget(Script.name(), RESET_POSITION)
// the rest of your widget code Tip: Change const RESET_POSITION = true to const RESET_POSITION = !config.runsInWidget to automatcally prompt for a new position every time you run the script inside the app
Now, you may want update the backgrounds after you change your wallpaper. For that, you can download the companion utility script No Background Config.js.
Download the script and run it.
This script has 2 options, Generate Slices and Clear Widget Positions Cache.
Use the Generate Slices option to update backgrounds from your current wallpaper.
Clear Widget Positions Cache will delete all saved positions from all widgets.
You'll have to run each individual widget to setup their positions.
If you have widgets that you are most likely not to move around, you can specify a its position using the getSlice method.
const nobg = importModule('no-background.js')
const widget = new ListWidget();
widget.backgroundImage = await nobg.getSlice('medium-top')
// the rest of your widget code Valid slice names are:
small-top-left/small-top-rightsmall-middle-left/small-middle-rightsmall-bottom-left/small-bottom-rightmedium-top/medium-middle/medium-bottomlarge-top/large-bottom
Sometimes you may want to get the actual path of the image for a specific posistion.
const nobg = importModule('no-background.js')
const widget = new ListWidget();
const bgpath = nobg.getPathForSlice('small-top-left')
widget.backgroundImage = Image.fromFile(bgpath)
// the rest of your widget code Like the getSliceForWidget method, both the getSlice and getPathForSlice also prompt for setup if the slices don't exist.
- nobg-small-top-left-widget.js - a very basic example for a widget on a fixed position
- nobg-configurable-widget-template.js - example widget where the possition can be set at run-time
- weather-widget-414.js - weather example based off the code by @eqsOne
- semi-transparent-widget.js - example widget with a semi-transparent background

