├── .gitignore ├── .travis.yml ├── CHANGELOG.md ├── CONTRIBUTING.md ├── LICENSE.md ├── README.md ├── bin.js ├── package.json ├── spacewall.js ├── test └── index.js └── usage.txt /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | 5 | # Runtime data 6 | pids 7 | *.pid 8 | *.seed 9 | 10 | # Directory for instrumented libs generated by jscoverage/JSCover 11 | lib-cov 12 | 13 | # Coverage directory used by tools like istanbul 14 | coverage 15 | 16 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 17 | .grunt 18 | 19 | # node-waf configuration 20 | .lock-wscript 21 | 22 | # Compiled binary addons (http://nodejs.org/api/addons.html) 23 | build/Release 24 | 25 | # Dependency directory 26 | # https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git 27 | node_modules 28 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - '0.12' 4 | - 'iojs' 5 | sudo: false 6 | cache: 7 | directories: 8 | - node_modules 9 | script: 10 | - npm test 11 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # spacewall change log 2 | 3 | All notable changes to this project will be documented in this file. 4 | This project adheres to [Semantic Versioning](http://semver.org/). 5 | 6 | ## 1.0.6 7 | * Fix some typos 8 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing Guidelines 2 | 3 | Contributions welcome! 4 | 5 | **Before spending lots of time on something, ask for feedback on your idea first!** 6 | 7 | Please search issues and pull requests before adding something new to avoid duplicating efforts and conversations. 8 | 9 | In addition to improving the project by refactoring code and implementing relevant features, this project welcomes the following types of contributions: 10 | 11 | - **Ideas**: participate in an issue thread or start your own to have your voice heard. 12 | - **Writing**: contribute your expertise in an area by helping expand the included content. 13 | - **Copy editing**: fix typos, clarify language, and generally improve the quality of the content. 14 | - **Formatting**: help keep content easy to read with consistent formatting. 15 | 16 | ## Installing 17 | 18 | Fork and clone the repo, then `npm install` to install all dependencies. 19 | 20 | ## Testing 21 | 22 | Tests are run with `npm test`. Unless you're creating a failing test to increase test coverage or show a problem, please make sure all tests are passing before submitting a pull request. 23 | 24 | ## Code Style 25 | 26 | [![standard][standard-image]][standard-url] 27 | 28 | This repository uses [`standard`][standard-url] to maintain code style and consistency and avoid style arguments. `npm test` runs `standard` so you don't have to! 29 | 30 | [standard-image]: https://cdn.rawgit.com/feross/standard/master/badge.svg 31 | [standard-url]: https://github.com/feross/standard 32 | [semistandard-image]: https://cdn.rawgit.com/flet/semistandard/master/badge.svg 33 | [semistandard-url]: https://github.com/Flet/semistandard 34 | 35 | --- 36 | 37 | # Collaborating Guidelines 38 | 39 | **This is an OPEN Open Source Project.** 40 | 41 | ## What? 42 | 43 | Individuals making significant and valuable contributions are given commit access to the project to contribute as they see fit. This project is more like an open wiki than a standard guarded open source project. 44 | 45 | ## Rules 46 | 47 | There are a few basic ground rules for collaborators: 48 | 49 | 1. **No `--force` pushes** or modifying the Git history in any way. 50 | 1. **Non-master branches** ought to be used for ongoing work. 51 | 1. **External API changes and significant modifications** ought to be subject to an **internal pull request** to solicit feedback from other collaborators. 52 | 1. Internal pull requests to solicit feedback are *encouraged* for any other non-trivial contribution but left to the discretion of the contributor. 53 | 1. Contributors should attempt to adhere to the prevailing code style. 54 | 55 | ## Releases 56 | 57 | Declaring formal releases remains the prerogative of the project maintainer. 58 | 59 | ## Changes to this arrangement 60 | 61 | This is an experiment and feedback is welcome! This document may also be subject to pull requests or changes by collaborators where you believe you have something valuable to add or change. 62 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright (c) 2015, Dan Flettre 2 | 3 | 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. 4 | 5 | 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 6 | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 7 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # spacewall 2 | 3 | [![npm][npm-image]][npm-url] 4 | [![travis][travis-image]][travis-url] 5 | 6 | [npm-image]: https://img.shields.io/npm/v/spacewall.svg?style=flat-square 7 | [npm-url]: https://www.npmjs.com/package/spacewall 8 | [travis-image]: https://img.shields.io/travis/flet/spacewall.svg?style=flat-square 9 | [travis-url]: https://travis-ci.org/flet/spacewall 10 | 11 | Set your wallpaper to the NASA Astronomy Photo of the Day and output 12 | information about the image. 13 | 14 | ## Install 15 | 16 | ``` 17 | npm install -g spacewall 18 | ``` 19 | 20 | ## CLI Usage 21 | 22 | ### Set your wallpaper to the current day's APOD: 23 | ```bash 24 | spacewall 25 | ``` 26 | 27 | ### ...To a random image 28 | ``` 29 | spacewall --random 30 | ``` 31 | 32 | ### Full Usage 33 | 34 | ``` 35 | Usage: 36 | spacewall 37 | 38 | Flags: 39 | -k --key Provide your NASA developer key (recommended!) 40 | -l --latest Fetch the latest APOD image (default) 41 | -r --random Pick a random image from the archive 42 | -s --silent Suppress all text output 43 | -t --title Output only the title of the image 44 | -j --json Show information as JSON 45 | -h, --help Show usage information. 46 | -v --version Show current version. 47 | 48 | By Default, spacewall will use DEMO_KEY. Its limited to 30 requests per hour 49 | and 50 requests per day. 50 | 51 | Get your own NASA developer key at: 52 | https://api.nasa.gov/api.html#authentication 53 | 54 | The API key can also be set via the environment variable NASA_API_KEY. 55 | ``` 56 | 57 | ## Programmatic Usage 58 | 59 | `spacewall` was built primarily as a CLI program, but it can be `require`'d and used directly as well! 60 | 61 | ```js 62 | var spacewall = require('spacewall') 63 | spacewall({ 64 | key: 'MY_API_KEY', 65 | latest: true, // default 66 | random: false, 67 | silent: false, 68 | title: false, 69 | json: false 70 | }) 71 | ``` 72 | Each option works as described in the CLI usage. 73 | 74 | ## NASA API Developer key 75 | `spacewall` is set up to use the `DEMO_KEY`, which is rate-limited to 30 requests per hour and 50 requests per day. Go [sign up](https://api.nasa.gov/api.html#authentication) for your on NASA API developer key to avoid these limits. 76 | 77 | Also, you can tell people "I'm authorized to use NASA's API, no big deal." and they will surely be impressed. 78 | 79 | ## Fun Tricks 80 | 81 | On Ubuntu (and maybe other Linux flavors), this command can be added to a `.profile` to change the wallpaper to a random image and send a notification to the UI with the title: 82 | ```bash 83 | notify-send -i computer "$(spacewall --random --title) 84 | ``` 85 | 86 | Are you using `spacewall` in a fun way? Add your Fun Trick here via a PR! 87 | 88 | ## Contributing 89 | 90 | Contributions welcome! Please read the [contributing guidelines](CONTRIBUTING.md) first. 91 | 92 | ## License 93 | 94 | [ISC](LICENSE.md) 95 | -------------------------------------------------------------------------------- /bin.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | var fs = require('fs') 3 | var argv = require('minimist')(process.argv.slice(2), { 4 | boolean: ['help', 'random', 'latest', 'version'], 5 | alias: { 6 | j: 'json', 7 | k: 'key', 8 | r: 'random', 9 | l: 'latest', 10 | h: 'help', 11 | s: 'silent', 12 | t: 'title', 13 | v: 'version' 14 | } 15 | }) 16 | 17 | if (argv.help) { 18 | fs.readFile('usage.txt', {encoding: 'utf8'}, function (err, usage) { 19 | if (err) console.error(err) 20 | console.log(usage, fetchVersion()) 21 | process.exit(0) 22 | }) 23 | } 24 | 25 | if (argv.version) { 26 | console.log(fetchVersion()) 27 | process.exit(0) 28 | } 29 | 30 | function fetchVersion () { 31 | var pkg = require('./package.json') 32 | return pkg.version 33 | } 34 | 35 | var spacewall = require('./spacewall.js') 36 | 37 | spacewall(argv) 38 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "spacewall", 3 | "version": "1.0.7", 4 | "description": "Set your wallpaper to the NASA Astronomy Photo of the Day.", 5 | "author": "Dan Flettre ", 6 | "bin": "./bin.js", 7 | "bugs": { 8 | "url": "https://github.com/flet/spacewall/issues" 9 | }, 10 | "devDependencies": { 11 | "snazzy": "^1.0.1", 12 | "tap-spec": "^4.0.2", 13 | "tape": "^4.0.1" 14 | }, 15 | "homepage": "https://github.com/flet/spacewall", 16 | "keywords": [ 17 | "Astronomy", 18 | "api", 19 | "cli", 20 | "desktop", 21 | "nasa", 22 | "photo", 23 | "random", 24 | "space", 25 | "wallpaper" 26 | ], 27 | "license": "ISC", 28 | "main": "spacewall.js", 29 | "repository": { 30 | "type": "git", 31 | "url": "https://github.com/flet/spacewall.git" 32 | }, 33 | "scripts": { 34 | "test": "snazzy && tape test/*.js | tap-spec" 35 | }, 36 | "dependencies": { 37 | "apod": "^0.3.0", 38 | "minimist": "^1.1.2", 39 | "os-tmpdir": "^1.0.1", 40 | "request": "^2.60.0", 41 | "wallpaper": "^1.1.0" 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /spacewall.js: -------------------------------------------------------------------------------- 1 | module.exports = spacewall 2 | 3 | var apod = require('apod') 4 | var fs = require('fs') 5 | var path = require('path') 6 | var req = require('request') 7 | var tmp = require('os-tmpdir')() 8 | 9 | var wallpaper = require('wallpaper') 10 | 11 | function spacewall (opts) { 12 | opts = opts || {} 13 | 14 | apod.apiKey = opts.key || process.env.NASA_API_KEY || 'DEMO_KEY' 15 | 16 | if (opts.random) { 17 | apod.random(processApod) 18 | } else { 19 | apod(processApod) 20 | } 21 | 22 | function processApod (err, data) { 23 | if (err) { 24 | console.error(err) 25 | return 26 | } 27 | 28 | var dest = path.join(tmp, path.parse(data.url).base) 29 | var stream = req(data.url).pipe(fs.createWriteStream(dest)) 30 | 31 | stream.on('finish', function () { 32 | wallpaper.set(dest, function (err) { 33 | if (err) console.error(err) 34 | }) 35 | 36 | if (!opts.silent) outputData(data) 37 | }) 38 | } 39 | 40 | function outputData (data) { 41 | if (opts.title) { 42 | console.log(data.title) 43 | return 44 | } 45 | 46 | if (opts.json) { 47 | console.log(data) 48 | return 49 | } 50 | 51 | console.log(data.title) 52 | console.log(data.explanation) 53 | 54 | if (apod.apiKey === 'DEMO_KEY') { 55 | console.log('*** Get your NASA developer key to avoid rate limits!') 56 | console.log('*** https://api.nasa.gov/api.html#authentication') 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /test/index.js: -------------------------------------------------------------------------------- 1 | var test = require('tape') 2 | 3 | test('testing is hard', function (t) { 4 | t.plan(1) 5 | t.ok(1, 'yep!') 6 | }) 7 | -------------------------------------------------------------------------------- /usage.txt: -------------------------------------------------------------------------------- 1 | spacewall %s 2 | Set your wallpaper to the NASA Astronomy Photo of the Day and output 3 | information about the photo. 4 | 5 | Usage: 6 | spacewall 7 | 8 | Flags: 9 | -k --key Provide your NASA developer key (recommended!) 10 | -l --latest Fetch the latest APOD image (default) 11 | -r --random Pick a random image from the archive 12 | -s --silent Suppress all text output 13 | -t --title Output only the title of the image 14 | -j --json Show information as JSON 15 | -h, --help Show usage information. 16 | -v --version Show current version. 17 | 18 | By Default, spacewall will use DEMO_KEY. Its limited to 30 requests per hour 19 | and 50 requests per day. 20 | 21 | Get your own NASA developer key at: 22 | https://api.nasa.gov/api.html#authentication 23 | 24 | The API key can also be set via the environment variable NASA_API_KEY. 25 | 26 | Full Readme: https://github.com/flet/spacewall 27 | --------------------------------------------------------------------------------