Created
July 13, 2019 13:56
-
-
Save danielgospodinow/5d93b38699c0900bf1ece36f4b4fad43 to your computer and use it in GitHub Desktop.
Screentopia - update desktop background wallpaper
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async function updateBackground(imageResolution, imageCategories, imageDirectory) { | |
console.log("Starting wallpaper change procedure ..."); | |
try { | |
const imageResponse = await fetch(`https://source.unsplash.com/featured/${imageResolution}?${imageCategories}`); | |
const image = await download.image({ url: imageResponse.url, dest: imageDirectory }); | |
await wallpaper.set(image.filename); | |
console.log("Wallpaper changed successfully!"); | |
} catch (e) { | |
console.error("Failed to fetch an image and set it as a background!", e); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment