Skip to content

Commit

Permalink
🚀 engage
Browse files Browse the repository at this point in the history
  • Loading branch information
ungoldman committed Feb 9, 2016
0 parents commit de135c1
Show file tree
Hide file tree
Showing 8 changed files with 227 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitignore
@@ -0,0 +1,4 @@
logs
*.log
.DS_Store
node_modules
1 change: 1 addition & 0 deletions .npmignore
@@ -0,0 +1 @@
screenshot.jpg
5 changes: 5 additions & 0 deletions LICENSE
@@ -0,0 +1,5 @@
Copyright (c) 2016, Nate Goldman <nate@ngoldman.me>

Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
81 changes: 81 additions & 0 deletions README.md
@@ -0,0 +1,81 @@
# himawari-bg

> Set the latest image from Himawari 8 as your desktop background
[![npm][npm-image]][npm-url]
[![travis][travis-image]][travis-url]
[![standard][standard-image]][standard-url]

[npm-image]: https://img.shields.io/npm/v/himawari-bg.svg?style=flat-square
[npm-url]: https://www.npmjs.com/package/himawari-bg
[travis-image]: https://img.shields.io/travis/ngoldman/himawari-bg.svg?style=flat-square
[travis-url]: https://travis-ci.org/ngoldman/himawari-bg
[standard-image]: https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square
[standard-url]: http://npm.im/standard

![](screenshot.jpg)

Note: This is alpha quality! Tested only on OSX.

## Install

```
npm i -g himawari-bg
```

## Usage

```js
var bg = require('himawari-bg')

bg({
/**
* The location to save the resulting image.
* Default: `~/Pictures/himawari-images/${Date.now()}.jpg`
* @type {String}
*/
outfile: '/path/to/output/earth.jpg',

/**
* The time of the picture desired. If you want to get the latest image, use 'latest'.
* Default: 'latest'
* @type {String|Date}
*/
date: 'latest', // Or new Date() or a date string

/**
* The zoom level of the image. Can be 1-5 (default: 1)
* Each zoom level requires more images to be downloaded and therefore stitched
* together. Higher zoom yields a higher resolution image.
* Default: 2
* @type {Number}
*/
zoom: 2,

/**
* If set to true, an image on the infrared light spectrum will be generated
* Default: false
* @type {Boolean}
*/
infrared: false
})
```

### Command Line Interface

```
Usage: himawari-bg [options]
--outfile, -o The location to save the resulting image. (default: `~/Pictures/himawari-images/${Date.now()}.jpg`)
--zoom, -z The zoom level of the image. Can be 1-5. (default: 2)
--date, -d The time of the picture desired. If you want to get the latest image, use "latest". (default: "latest")
--infrared, -i Capture picture on the infrared spectrum. (default: false)
--help, -h Show help.
```

### Acknowledgement

Thanks to [celoyd](https://github.com/celoyd) for the inspiring [glittering.blue](https://glittering.blue/) and [jakiewtf](https://github.com/jakiestfu) for creating [himawari.js](https://github.com/jakiestfu/himawari.js).

## License

[ISC](LICENSE)
49 changes: 49 additions & 0 deletions cli.js
@@ -0,0 +1,49 @@
#!/usr/bin/env node

var bg = require('./')
var cliclopts = require('cliclopts')
var minimist = require('minimist')

var allowedOptions = [
{
name: 'outfile',
abbr: 'o',
help: 'Location to save image. (default: `~/Pictures/himawari-images/${Date.now()}.jpg`)'
},
{
name: 'zoom',
abbr: 'z',
help: 'The zoom level of the image. Can be 1-5.',
default: 2
},
{
name: 'date',
abbr: 'd',
help: 'Time of the picture desired. Can also be "latest".',
default: 'latest'
},
{
name: 'infrared',
abbr: 'i',
help: 'Capture picture on the infrared spectrum.',
boolean: true,
default: false
},
{
name: 'help',
abbr: 'h',
help: 'Show help.',
boolean: true
}
]

var opts = cliclopts(allowedOptions)
var argv = minimist(process.argv.slice(2), opts.options())

if (argv.help) {
console.log('Usage: himawari-bg [options]')
opts.print()
process.exit()
}

bg(argv)
43 changes: 43 additions & 0 deletions index.js
@@ -0,0 +1,43 @@
var himawari = require('himawari')
var path = require('path')
var wallpaper = require('wallpaper')
var mkdirp = require('mkdirp')
var ProgressBar = require('progress')
var untildify = require('untildify')
var bar = null

module.exports = function (opts) {
var outfile = untildify(opts.outfile || `~/Pictures/himawari-images/${Date.now()}.jpg`)

// create outfile directory just in case
mkdirp.sync(path.dirname(outfile))

himawari({
zoom: opts.zoom || 2,
outfile: outfile,
date: opts.date || 'latest',
infrared: opts.infrared || false,
chunk: function (info) {
bar = bar || createProgressBar(info.total)
bar.tick()
},
error: function (err) {
console.log(err)
process.exit(1)
},
success: function () {
console.log(`Setting ${outfile} as background...`)
wallpaper.set(outfile)
console.log('Complete!')
}
})
}

function createProgressBar (total) {
return new ProgressBar('Downloading satellite images [:bar] :percent :etas', {
complete: '=',
incomplete: ' ',
width: 20,
total: total
})
}
44 changes: 44 additions & 0 deletions package.json
@@ -0,0 +1,44 @@
{
"name": "himawari-bg",
"description": "Set the latest image from Himawari 8 as your desktop background",
"version": "1.0.0-alpha",
"author": "Nate Goldman <nate@ngoldman.me>",
"bugs": {
"url": "https://github.com/ngoldman/himawari-bg/issues"
},
"dependencies": {
"cliclopts": "^1.1.1",
"himawari": "^1.1.1",
"minimist": "^1.2.0",
"mkdirp": "^0.5.1",
"progress": "^1.1.8",
"untildify": "^2.1.0",
"wallpaper": "^2.1.0"
},
"devDependencies": {
"standard": "^6.0.4"
},
"bin": {
"himawari-bg": "./cli.js"
},
"homepage": "https://github.com/ngoldman/himawari-bg",
"keywords": [
"background",
"desktop",
"earth",
"himawari",
"himawari-8",
"satellite",
"wallpaper"
],
"license": "ISC",
"main": "index.js",
"repository": {
"type": "git",
"url": "https://github.com/ngoldman/himawari-bg.git"
},
"scripts": {
"start": "node index.js",
"test": "standard"
}
}
Binary file added screenshot.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit de135c1

Please sign in to comment.