Last active
October 24, 2018 00:05
-
-
Save HackingGate/6cf63d2d47d7e80730bc4507ffe85e3d to your computer and use it in GitHub Desktop.
Set latest himawari earth dynamic wallpaper in every 10 minutes for macOS (ひまわり8号リアルタイム壁紙)
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
const { exec } = require('child_process'); | |
var glob = require("glob") | |
var cronTime = '*/10 * * * *'; | |
CronJob = require('cron').CronJob; | |
var job = new CronJob({ | |
cronTime: cronTime, | |
onTick: function() { | |
var himawari = require('himawari'); | |
himawari({ | |
zoom: 2, | |
date: 'latest', | |
debug: false, | |
infrared: false, | |
skipEmpty: true, | |
success: function (info) { | |
glob("[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]_[0-9][0-9][0-9][0-9][0-9][0-9].jpg", function (err, files) { | |
var last_file = files[files.length - 1]; | |
console.log('Setting ' + last_file); | |
exec('wallpaper set ' + last_file + ' --screen main --scale fit', (err, stdout, stderr) => { | |
if (err) { | |
console.log('Set wallpaper failed'); | |
return; | |
} | |
console.log('Changed wallpaper'); | |
}); | |
for (var i = 0; i < files.length - 100; i++) { | |
exec ('rm -v ' + files[i], (err, stdout, stderr) => { | |
if (stdout) { | |
console.log('Deleted ' + stdout); | |
} | |
}); | |
} | |
}); | |
}, | |
error: function (err) { | |
console.log(err); | |
}, | |
chunk: function (info) { | |
console.log('Saved' + ': ' + info.part + '/' + info.total); | |
} | |
}); | |
}, | |
start: false | |
}); | |
job.fireOnTick(); | |
job.start(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Getting Started
brew install wallpaper
brew install imagemagick
brew install graphicsmagick
npm i himawari
npm i cron
npm i glob
Run himawari.js
node himawari.js