mvan231

Scriptable Simple Image Widget

Dec 15th, 2022
368
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1.  
  2. //set the filename of the image. Example: image in iCloud Drive/Scriptable which has the name "WBack.jpeg"
  3. let filename = "WBack.jpeg"
  4.  
  5. //setup the fiie manager
  6. let fm = FileManager.iCloud()
  7.  
  8. //build the full path of the image
  9. let path = fm.joinPath(fm.documentsDirectory(),filename)
  10.  
  11. log(`path is ${path}`)
  12.  
  13. //retrieve the image
  14. let image = fm.readImage(path)
  15.  
  16. //start to build the widget
  17. let w = new ListWidget()
  18. //set background image as the image variable
  19. w.backgroundImage = image
  20. //set the widget
  21. Script.setWidget(w)
  22. //complete the script
  23. Script.complete()
  24. //display a preview when running in app
  25. //w.presentLarge()
Advertisement
Add Comment
Please, Sign In to add comment