Skip to content

About

💻 Console application for creating dynamic wallpapers for macOS Mojave and newer

Topics

Resources

Stars

3.4k stars

Watchers

51 watching

Forks

Latest commit

 

History

71 Commits

Folders and files

Repository files navigation

💻 wallpapper / wallpapper-exif

Build Status Swift 6.4 Swift Package Manager Platforms OS X | Linux

wallpaper

This is a console application for macOS 12 and later that creates the dynamic wallpapers introduced in macOS Mojave. Here you can watch how dynamic wallpapers work. Also, you can read more about dynamic wallpapers in the following articles:

Examples

Below you can download prepared dynamic wallpapers:

Build and install

Building from source requires Swift 6.4 or later and the macOS SDK from Xcode 27 or later. CI uses Swift 6.4.3.

Homebrew

Open your terminal and run the following commands.

brew tap mczachurski/wallpapper
brew install wallpapper

Manually

Open your terminal and run the following commands.

$ git clone https://github.com/mczachurski/wallpapper.git
$ cd wallpapper
$ swift build --configuration release
$ bin_path=$(swift build --configuration release --show-bin-path)
$ sudo cp "$bin_path/wallpapper" "$bin_path/wallpapper-exif" /usr/local/bin/

You can also use build.sh to build both executables and copy them to output/.

$ git clone https://github.com/mczachurski/wallpapper.git
$ cd wallpapper
$ ./build.sh
$ sudo cp output/wallpapper output/wallpapper-exif /usr/local/bin/

Now in the console you can run wallpapper -h and you should get a response similar to the following one.

wallpapper: [command_option] [-i jsonFile] [-e heicFile]
Command options are:
 -h            show this message and exit
 -v            show program version and exit
 -o            output file name (default is 'output.heic')
 -i            input .json file with wallpaper description
 -e            input .heic file to extract metadata
 -q            quality of the output images (default is 1.0)

That's all. Now you can build your own dynamic wallpapers.

Troubleshooting

If you get an error during the Swift build portion of the install, try downloading the entire Xcode IDE (not just the tools) from the App Store. Then run

sudo xcode-select -s /Applications/Xcode.app/Contents/Developer 

and run the installation command again.

Getting started

If you have done the above commands, now you can build a dynamic wallpaper. It's really easy. First, you have to put all your pictures into one folder and, in the same folder, create a json file with the pictures' descriptions. The application supports three kinds of dynamic wallpapers.

Solar

For a wallpaper that is based on solar coordinates, the json file has to have a structure like the snippet below.

[
  {
    "fileName": "1.png",
    "isPrimary": true,
    "isForLight": true,
    "altitude": 27.95,
    "azimuth": 279.66
  },
  {
    "fileName": "2.png",
    "altitude": -31.05,
    "azimuth": 4.16
  },
  ...
  {
    "fileName": "16.png",
    "isForDark": true,
    "altitude": -28.63,
    "azimuth": 340.41
  }
]

Properties:

  • fileName - name of the picture file (you can use the same file for a few nodes).
  • isPrimary - information about the image that is the primary image (it will be visible after creating the heic file). Only one of the files can be primary.
  • isForLight - if true, the picture will be displayed when the user chooses "Light (static)" wallpaper
  • isForDark - if true, the picture will be displayed when the user chooses "Dark (static)" wallpaper
  • altitude - is the angle between the Sun and the observer's local horizon.
  • azimuth - that is the angle of the Sun around the horizon.

To calculate proper altitude and azimuth, you can use the wallpapper-exif application or a web page: https://gml.noaa.gov/grad/solcalc/azel.html or https://www.omnicalculator.com/physics/sun-angle. On the web page, you have to enter the place where you take a photo and the date. Then the system generates for you the altitude and azimuth of the Sun during the whole day.

Solar frames change too early

macOS selects the displayed frame using the solar positions stored in the HEIC. If the dawn image appears around midnight, try adding a solar position for your night image on the eastern side of the sky. If the daytime image changes too early around noon, try adding a position for that image on the western side. You can reuse the same fileName for multiple positions. Wallpapper embeds each image once.

For the configuration in issue #78, add these two entries to the existing JSON array and regenerate the HEIC:

[
  { "fileName": "night.jpeg", "altitude": -20, "azimuth": 60 },
  { "fileName": "day.jpeg", "altitude": 60, "azimuth": 250 }
]

These coordinates are a starting point for that example. Adjust the positions for your location and desired transitions. For changes at fixed local times, use a time-based wallpaper.

Time

For a wallpaper that is based on the OS time json file have to have a structure like the snippet below.

[
    {
        "fileName": "1.png",
        "isPrimary": true,
        "isForLight": true,
        "time": "10:25:43"
    },
    {
        "fileName": "2.png",
        "time": "14:32:12"
    },
    {
        "fileName": "3.png",
        "time": "18:12:01"
    },
    {
        "fileName": "4.png",
        "isForDark": true,
        "time": "20:10:45"
    }
]

Properties:

  • fileName - name of picture file (you can use the same file for a few nodes).
  • isPrimary - information about the image that is the primary image (it will be visible after creating the heic file). Only one of the files can be primary.
  • isForLight - if true, the picture will be displayed when the user chooses "Light (static)" wallpaper
  • isForDark - if true, the picture will be displayed when the user chooses "Dark (static)" wallpaper
  • time - local time of the transition in HH:mm:ss format. Wallpapper stores transitions with minute precision. If you supply a timestamp with a time zone offset, Wallpapper converts it to the local time zone of the Mac that generates the HEIC.

If the schedule has no transition at midnight, Wallpapper uses the last scheduled frame of the previous day from 00:00 until the first transition. Add an explicit 00:00:00 entry to choose a different frame at midnight.

Appearance

For wallpapers based on OS appearance settings (light/dark), we have to prepare a much simpler JSON file, and we have to use only two images (one for light and one for dark theme).

[
    {
        "fileName": "1.png",
        "isPrimary": true,
        "isForLight": true
    },
    {
        "fileName": "2.png",
        "isForDark": true
    }
]

Properties:

  • fileName - name of the picture file.
  • isPrimary - information about the image that is the primary image (it will be visible after creating the heic file). Only one of the files can be primary.
  • isForLight - if true, the picture will be displayed when the user uses the light theme
  • isForDark - if true, the picture will be displayed when the user uses the dark theme

Preparing wallpapers

When you have a json file and all pictures, then you can generate a heic file. You have to run the following command:

wallpapper -i wallpapper.json

You should get a new file: output.heic. Set this file as a new wallpaper and enjoy your own dynamic wallpaper!

Extracting metadata

You can extract metadata from an existing heic file. You have to run the following command:

wallpapper -e Catalina.heic

Metadata should be printed as output on the console.

Also, it's possible to extract and save the whole plist file:

wallpapper -e Catalina.heic -o output.plist

Calculating sun position

If your photos contain GPS Exif metadata and creation time, you can use the wallpapper-exif application to generate a json file with Sun altitude and azimuth. Example application usage:

$ wallpapper-exif 1.jpeg 2.jpeg 3.jpeg

json should be produced as output on the console.

Sun calculations have been created based on the JavaScript library created by Vladimir Agafonkin (@mourner).

Creating a schedule from photo capture times

Use wallpapper-exif --time to generate a time-based configuration from the local capture times stored in your photos. This mode works with photos that have no GPS metadata.

wallpapper-exif --time --primary day.jpg --light day.jpg --dark night.jpg photos/*.jpg > wallpapper.json
wallpapper -i wallpapper.json

The optional --primary, --light and --dark flags take exact filenames, including the extension. Each must match exactly one input. The generated JSON contains absolute image paths, so you can save it in a different directory. Capture time comes from EXIF DateTimeOriginal, with XMP CreateDate as a fallback. The schedule uses the clock time recorded in the photo. If a capture date is missing or invalid, the command reports the file and exits with an error.

About

💻 Console application for creating dynamic wallpapers for macOS Mojave and newer

Topics

Resources

Stars

3.4k stars

Watchers

51 watching

Forks

Releases

Packages

Used by

Contributors

Languages