wallpaper
Advanced tools
Comparing version 6.1.1 to 7.0.0
@@ -1,2 +0,2 @@ | ||
export interface GetOptions { | ||
export type GetOptions = { | ||
/** | ||
@@ -12,5 +12,5 @@ __macOS only.__ | ||
readonly screen?: 'all' | 'main' | number; | ||
} | ||
}; | ||
export interface SetOptions { | ||
export type SetOptions = { | ||
/** | ||
@@ -30,10 +30,14 @@ __macOS only.__ | ||
/** | ||
__macOS only.__ | ||
__macOS & Windows__ | ||
Scaling method. Values: `auto` `fill` `fit` `stretch` `center`. | ||
Scaling method. | ||
@default 'auto' | ||
macOS Values: `auto` `fill` `fit` `stretch` `center`. | ||
Windows Values: `stretch` `center` `tile` `span` `max` `crop-to-fit` `keep-aspect-ratio`. | ||
@default 'auto' for macOS | ||
@default 'span' for Windows | ||
*/ | ||
readonly scale?: 'auto' | 'fill' | 'fit' | 'stretch' | 'center'; | ||
} | ||
readonly scale?: 'auto' | 'fill' | 'fit' | 'stretch' | 'center' | 'tile' | 'span'; | ||
}; | ||
@@ -40,0 +44,0 @@ /** |
{ | ||
"name": "wallpaper", | ||
"version": "6.1.1", | ||
"version": "7.0.0", | ||
"description": "Manage the desktop wallpaper", | ||
@@ -15,3 +15,3 @@ "license": "MIT", | ||
"engines": { | ||
"node": "^12.20.0 || ^14.13.1 || >=16.0.0" | ||
"node": ">=16" | ||
}, | ||
@@ -38,5 +38,5 @@ "scripts": { | ||
"devDependencies": { | ||
"ava": "^4.0.1", | ||
"tsd": "^0.19.1", | ||
"xo": "^0.47.0" | ||
"ava": "^5.3.1", | ||
"tsd": "^0.28.1", | ||
"xo": "^0.54.2" | ||
}, | ||
@@ -43,0 +43,0 @@ "ava": { |
@@ -70,7 +70,9 @@ # wallpaper | ||
##### scale *(macOS only)* | ||
##### scale *(macOS & Windows)* | ||
Type: `string`\ | ||
Values: `'auto' | 'fill' | 'fit' | 'stretch' | 'center'`\ | ||
Default: `'auto'` | ||
macOS Values: `'auto' | 'fill' | 'fit' | 'stretch' | 'center'`\ | ||
Windows Values: `'center' | 'stretch' | 'tile' | 'span' | 'fit' | 'fill'`\ | ||
Default macOS: `'auto'`\ | ||
Default Windows: `'span'` | ||
@@ -130,3 +132,3 @@ Scaling method. | ||
You can also do this with Electron on macOS and Linux by using [`new BrowserWindow({type: 'desktop'})`](https://electronjs.org/docs/api/browser-window#new-browserwindowoptions). | ||
You can also do this with Electron on macOS and Linux by using [`new BrowserWindow({type: 'desktop'})`](https://www.electronjs.org/docs/latest/api/browser-window#new-browserwindowoptions). | ||
@@ -133,0 +135,0 @@ On Windows, you can use [Wallpaper Engine](https://wallpaperengine.io). It's available on Steam, HumbleBundle, and Green Man Gaming for around 4 USD. |
@@ -32,3 +32,3 @@ import path from 'node:path'; | ||
if (typeof imagePath !== 'undefined') { | ||
if (imagePath !== undefined) { | ||
if (!wallpapersVoted.get(imagePath)) { | ||
@@ -35,0 +35,0 @@ wallpapersVoted.set(imagePath, 0); |
@@ -10,10 +10,14 @@ import {promisify} from 'node:util'; | ||
// Binary source → https://github.com/sindresorhus/win-wallpaper | ||
const binary = path.join(__dirname, 'windows-wallpaper.exe'); | ||
const binary = path.join(__dirname, 'windows-wallpaper-x86-64.exe'); | ||
export async function getWallpaper() { | ||
const {stdout} = await execFile(binary); | ||
const arguments_ = [ | ||
'get', | ||
]; | ||
const {stdout} = await execFile(binary, arguments_); | ||
return stdout.trim(); | ||
} | ||
export async function setWallpaper(imagePath) { | ||
export async function setWallpaper(imagePath, {scale = 'fill'} = {}) { | ||
if (typeof imagePath !== 'string') { | ||
@@ -23,3 +27,10 @@ throw new TypeError('Expected a string'); | ||
await execFile(binary, [path.resolve(imagePath)]); | ||
const arguments_ = [ | ||
'set', | ||
path.resolve(imagePath), | ||
'--scale', | ||
scale, | ||
]; | ||
await execFile(binary, arguments_); | ||
} |
6627745
441
141