Skip to content

Instantly share code, notes, and snippets.

@HackingGate
Last active October 24, 2018 00:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save HackingGate/6cf63d2d47d7e80730bc4507ffe85e3d to your computer and use it in GitHub Desktop.
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号リアルタイム壁紙)
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();
@HackingGate
Copy link
Author

HackingGate commented Oct 6, 2018

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

@HackingGate
Copy link
Author

Example

screen shot 2018-10-06 at 16 00 38

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment