Go to file
Sindre Sorhus fac6b832ff 2.2.0 2021-09-16 18:19:29 +07:00
.github Enable the repo Sponsor button 2019-05-24 00:40:47 +07:00
Sources 2.2.0 2021-09-16 18:19:29 +07:00
.editorconfig meta tweaks 2016-03-26 16:11:26 +07:00
.gitattributes Upgrade to Swift 4.2 2018-09-26 11:27:19 +07:00
.gitignore Require Swift 5.2 2020-03-26 16:28:58 +08:00
Package.resolved Move to `swift-argument-parser` 2021-09-16 18:16:25 +07:00
Package.swift Move to `swift-argument-parser` 2021-09-16 18:16:25 +07:00
fixture.jpg add fixtures 2015-10-06 08:27:27 +07:00
fixture2.jpg add fixtures 2015-10-06 08:27:27 +07:00
license Minor tweaks 2020-04-22 00:06:15 +08:00
readme.md 2.2.0 2021-09-16 18:19:29 +07:00

readme.md

macos-wallpaper

Manage the desktop wallpaper on macOS

This is both a command-line app and a Swift package.

It correctly handles getting the active wallpaper even when the wallpaper is set to a directory.

Requires macOS 10.14.4 or later.

CLI

Install

Homebrew
$ brew install wallpaper
Manually

Download the binary and put it in /usr/local/bin.

Usage

By default, it sets and gets the wallpaper for all screens. Use the --screen flag to change this.

$ wallpaper

USAGE: wallpaper <subcommand>

OPTIONS:
  --version               Show the version.
  -h, --help              Show help information.

SUBCOMMANDS:
  get                     Get current wallpaper images.
  set                     Set image as wallpaper.
  set-solid-color         Set solid color as wallpaper.
  screens                 Get a list of available screens.
$ wallpaper get --help

OVERVIEW: Get current wallpaper images.

USAGE: wallpaper get [--screen <screen>]

OPTIONS:
  --screen <screen>       Values: all, main, <index> (default: all)
$ wallpaper set --help

OVERVIEW: Set image as wallpaper.

USAGE: wallpaper set <path> [--screen <screen>] [--scale <scale>] [--fill-color <fill-color>]

ARGUMENTS:
  <path>                  The path to the image to use as wallpaper.

OPTIONS:
  --screen <screen>       Values: all, main, <index> (default: all)
  --scale <scale>         Values: auto, fill, fit, stretch, center (default: auto)
  --fill-color <fill-color>
                          Format: Hex color <RRGGBB>
$ wallpaper set-solid-color --help

OVERVIEW: Set solid color as wallpaper.

USAGE: wallpaper set-solid-color <color> [--screen <screen>]

ARGUMENTS:
  <color>                 The color to use as wallpaper.

OPTIONS:
  --screen <screen>       Values: all, main, <index> (default: all)
Set
$ wallpaper set unicorn.jpg
Set solid color
$ wallpaper set-solid-color 0000ff
Get
$ wallpaper get
/Users/sindresorhus/unicorn.jpg

API

Install

Add the following to Package.swift:

.package(url: "https://github.com/sindresorhus/macos-wallpaper", from: "2.2.0")

Or add the package in Xcode.

Usage

import Wallpaper

let imageURL = URL(fileURLWithPath: "<path>", isDirectory: false)
try! Wallpaper.set(imageURL, screen: .main, scale: .fill)

let solidColor = NSColor.blue
try! Wallpaper.set(solidColor, screen: .main)

print(try! Wallpaper.get(screen: .main))

See the source for more.

Dev

Run

swift run wallpaper

Build

swift build --configuration=release