wallpaper
Advanced tools
Comparing version 4.4.0 to 4.4.1
@@ -6,4 +6,6 @@ declare namespace wallpaper { | ||
The screen to get the wallpaper from. Values: `all` `main` or the index of a screen from `.screens()`. | ||
The screen to get the wallpaper from. | ||
Values: `all`, `main`, or the index of a screen from `.screens()`. | ||
@default 'main' | ||
@@ -18,4 +20,6 @@ */ | ||
The screen to set the wallpaper on. Values: `all` `main` or the index of a screen from `.screens()`. | ||
The screen to set the wallpaper on. | ||
Values: `all`, `main`, or the index of a screen from `.screens()`. | ||
*On Linux and Windows it's hard-coded to `main`.* | ||
@@ -22,0 +26,0 @@ |
{ | ||
"name": "wallpaper", | ||
"version": "4.4.0", | ||
"version": "4.4.1", | ||
"description": "Manage the desktop wallpaper", | ||
@@ -35,3 +35,3 @@ "license": "MIT", | ||
"devDependencies": { | ||
"ava": "^1.4.1", | ||
"ava": "^2.1.0", | ||
"tsd": "^0.7.1", | ||
@@ -38,0 +38,0 @@ "xo": "^0.24.0" |
@@ -16,7 +16,3 @@ # wallpaper [![Build Status](https://travis-ci.org/sindresorhus/wallpaper.svg?branch=master)](https://travis-ci.org/sindresorhus/wallpaper) [![Build status](https://ci.appveyor.com/api/projects/status/xhwaihmhhplh5d05/branch/master?svg=true)](https://ci.appveyor.com/project/sindresorhus/wallpaper/branch/master) | ||
<a href="https://www.patreon.com/sindresorhus"> | ||
<img src="https://c5.patreon.com/external/logo/become_a_patron_button@2x.png" width="160"> | ||
</a> | ||
## Usage | ||
@@ -38,22 +34,24 @@ | ||
### .get([options]) | ||
### .get(options?) | ||
Returns a promise for the path of the current desktop wallpaper. | ||
Returns a `Promise<string>` with the path of the current desktop wallpaper. | ||
#### options | ||
Type: `Object` | ||
Type: `object` | ||
##### screen *(macOS only)* | ||
Type: `string` `number`<br> | ||
Values: `all` `main` or the index of a screen from `.screens()`<br> | ||
Default: `main` | ||
Type: `string | number`<br> | ||
Values: `'all'`, `'main'`, or the index of a screen from `.screens()`<br> | ||
Default: `'main'` | ||
The screen to get the wallpaper from. | ||
### .set(imagePath, [options]) | ||
If you set `'all'` then `.get()` will return a `Promise<string[]>`. | ||
Returns a promise. | ||
### .set(imagePath, options?) | ||
Returns a `Promise`. | ||
#### imagePath | ||
@@ -67,13 +65,13 @@ | ||
Type: `Object` | ||
Type: `object` | ||
##### screen *(macOS only)* | ||
Type: `string` `number`<br> | ||
Values: `all` `main` or the index of a screen from `.screens()` | ||
Default: `all` | ||
Type: `string | number`<br> | ||
Values: `'all'`, `'main'`, or the index of a screen from `.screens()` | ||
Default: `'all'` | ||
The screen to set the wallpaper on. | ||
*On Linux and Windows it's hard-coded to `main`.* | ||
*On Linux and Windows it's hard-coded to `'main'`.* | ||
@@ -83,4 +81,4 @@ ##### scale *(macOS only)* | ||
Type: `string`<br> | ||
Values: `auto` `fill` `fit` `stretch` `center`<br> | ||
Default: `auto` | ||
Values: `'auto' | 'fill' | 'fit' | 'stretch' | 'center'`<br> | ||
Default: `'auto'` | ||
@@ -91,3 +89,3 @@ Scaling method. | ||
Returns a promise for the available screens. | ||
Returns a `Promise<string[]>` with the available screens. | ||
@@ -108,6 +106,1 @@ ```js | ||
- [trash](https://github.com/sindresorhus/trash) - Move files and directories to the trash | ||
## License | ||
MIT © [Sindre Sorhus](https://sindresorhus.com) |
@@ -11,8 +11,14 @@ 'use strict'; | ||
exports.get = async () => { | ||
const {stdout} = await execFile(binary, ['get']); | ||
return stdout.trim(); | ||
exports.get = async ({screen = 'main'} = {}) => { | ||
let {stdout} = await execFile(binary, ['get', '--screen', screen]); | ||
stdout = stdout.trim(); | ||
if (screen === 'all') { | ||
return stdout.split('\n'); | ||
} | ||
return stdout; | ||
}; | ||
exports.set = async (imagePath, options) => { | ||
exports.set = async (imagePath, {screen = 'all', scale = 'auto'} = {}) => { | ||
if (typeof imagePath !== 'string') { | ||
@@ -22,8 +28,2 @@ throw new TypeError('Expected a string'); | ||
options = { | ||
screen: 'all', | ||
scale: 'auto', | ||
...options | ||
}; | ||
const arguments_ = [ | ||
@@ -33,5 +33,5 @@ 'set', | ||
'--screen', | ||
options.screen, | ||
screen, | ||
'--scale', | ||
options.scale | ||
scale | ||
]; | ||
@@ -38,0 +38,0 @@ |
413
11450413
101