Skip to content

Instantly share code, notes, and snippets.

@danielgospodinow
Created July 13, 2019 13:56
Show Gist options
  • Save danielgospodinow/5d93b38699c0900bf1ece36f4b4fad43 to your computer and use it in GitHub Desktop.
Save danielgospodinow/5d93b38699c0900bf1ece36f4b4fad43 to your computer and use it in GitHub Desktop.
Screentopia - update desktop background wallpaper
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