Go to file
Sindre Sorhus 2c393982e5 2.1.0 2020-05-04 14:07:33 +08:00
.github Enable the repo Sponsor button 2019-05-24 00:40:47 +07:00
Sources 2.1.0 2020-05-04 14:07:33 +08: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 Upgrade to Swift 5.1 2019-09-11 23:20:11 +07:00
Package.swift Minor tweaks 2020-04-22 00:06:15 +08: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.1.0 2020-05-04 14:07:33 +08: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.12 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 help

Usage: wallpaper <command> [options]

Manage the desktop wallpaper

Commands:
  set               Set wallpaper image
  set-solid-color   Set solid color wallpaper background
  get               Get current wallpaper image
  screens           List screens
  help              Prints help information
  version           Prints the current version of this app
$ wallpaper get --help

Usage: wallpaper get [options]

Get current wallpaper image

Options:
  --screen <value>    Values: all, main, <index> [Default: all]
  -h, --help          Show help information
$ wallpaper set --help

Usage: wallpaper set <path> [options]

Set wallpaper image

Options:
  --scale <value>         Values: auto, fill, fit, stretch, center [Default: auto]
  --screen <value>        Values: all, main, <index> [Default: all]
  --fill-color <value>    Format: Hex color <RRGGBB> [Default: nil]
  -h, --help              Show help information
$ wallpaper set-solid-color --help

Usage: wallpaper set-solid-color <color> [options]

Set solid color wallpaper background

Options:
  --screen <value>        Values: all, main, <index> [Default: all]
  -h, --help              Show help information
Set
$ wallpaper set unicorn.jpg
Set solid color
$ wallpaper set-solid-color 0000ff
Get
$ wallpaper get
/Users/sindresorhus/unicorn.jpg

API

Install

Swift Package Manager:

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

Usage

import Wallpaper

let imageURL = URL(fileURLWithPath: "<path>")
let solidColor = NSColor.blue

try! Wallpaper.set(imageURL, screen: .main, scale: .fill, fillColor: 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