I want to set background image of desktop from electron app.
I have a image hosted on server and i will display list of images and users can set that image after right click on to it.
How to achieve that?
This is what i am using it while creating window just to make sure that it is working.
function createWindow () {
win = new BrowserWindow({width: 800, height: 600})
win.webContents.openDevTools();
win.loadURL(url.format({
pathname: path.join(__dirname, 'index.html'),
protocol: 'file:',
slashes: true
}))
var download = function(uri, filename, callback){
request.head(uri, function(err, res, body){
console.log('content-type:', res.headers['content-type']);
console.log('content-length:', res.headers['content-length']);
request(uri).pipe(fs.createWriteStream(filename)).on('close', callback);
});
};
download('https://maxcdn.icons8.com/Share/icon/Logos//google_logo1600.png', 'google.png', function(){
wallpaper.set('google.png').then(()=>{
console.log("image set");
})
});
}