Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including wallpaper with all npm packages installed. Try it out:

var wallpaper = require("wallpaper")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

wallpaper v4.4.0

Manage the desktop wallpaper

wallpaper Build Status Build status

Get or set the desktop wallpaper

Works on macOS 10.12+, Linux, and Windows 10+.

Maintainer needed for the Linux part of the code. No new Linux-related changes will be accepted until someone with good Linux knowledge volunteers.

Install

$ npm install wallpaper

Usage

const wallpaper = require('wallpaper');

(async () => {
    await wallpaper.set('unicorn.jpg');

    await wallpaper.get();
    //=> '/Users/sindresorhus/unicorn.jpg'
})();

API

.get([options])

Returns a promise for the path of the current desktop wallpaper.

options

Type: Object

screen (macOS only)

Type: string number
Values: all main or the index of a screen from .screens()
Default: main

The screen to get the wallpaper from.

.set(imagePath, [options])

Returns a promise.

imagePath

Type: string

The path to the image to set as the desktop wallpaper.

options

Type: Object

screen (macOS only)

Type: string number
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.

scale (macOS only)

Type: string
Values: auto fill fit stretch center
Default: auto

Scaling method.

.screens() (macOS only)

Returns a promise for the available screens.

(async () => {
    await wallpaper.screens();
    //=> ['Color LCD']
})();

Related

License

MIT © Sindre Sorhus

Metadata

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free