Last active
July 17, 2025 04:54
-
-
Save rileypeterson/ab3d129fa5f5b03f4730763b8413bd87 to your computer and use it in GitHub Desktop.
MacOS wallpaper collector to enable rotating wallpapers
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# MacOS wallpaper collector to enable rotating wallpapers | |
# After running this script you go to Settings > Wallpaper > Add Folder... | |
# Add the output_wallpaper_folder (~/Desktop/Wallpapers) | |
# Then select Auto-Rotate | Change picture Every Day | Randomly | |
# Repeat for other monitors | |
import os | |
import glob | |
import shutil | |
from pathlib import Path | |
# These are the names of the wallpapers that I like. | |
# These two photos randomly don't have the same name as what's | |
# in the Settings > Wallpaper preview. | |
# They are found in: | |
# /Library/Desktop Pictures | |
# The corresponding names are: | |
# Yosemite Vista --> Yosemite 2 | |
# Yosemite Reflection --> Yosemite 5 | |
wallpaper_list = [ | |
"Big Sur Aerial", | |
"Big Sur Horizon", | |
"Big Sur Coastline", | |
"Catalina Coast", | |
"Catalina Evening", | |
"Catalina Shoreline", | |
"Catalina Silhouette", | |
"Catalina Silhouette", | |
"Yosemite 2", | |
"Yosemite 5", | |
"Earth and Moon", | |
"Earth Horizon", | |
"Bahamas Aerial", | |
] | |
# List of custom wallpapers. If you don't have any make this an empty list. | |
# Expect in ~/Downloads | |
# You may need to update the Privacy and Security settings | |
# to allow the Python process to access the Downloads folder | |
custom_wallpaper_list = ["Big Sur 1", "Catalina 5"] | |
# Where to check for wallpapers | |
# The folders to search for wallpapers comes from this answer: | |
# https://discussions.apple.com/thread/253322672?answerId=256564261022&sortBy=rank#256564261022 | |
folders = [ | |
"/Library/Desktop Pictures", | |
"~/Library/Application Support/com.apple.mobileAssetDesktop", | |
"/System/Library/Desktop Pictures", | |
"~/Downloads", | |
] | |
# Where to collect wallpapers | |
# You may need to update the Privacy and Security settings | |
# to allow the Python process to access the Desktop folder | |
output_wallpaper_folder = "~/Desktop/Wallpapers" | |
# Expected image extensions | |
img_extensions = {"jpg", "heic"} | |
if __name__ == "__main__": | |
# Resolve relative folders | |
folders = [Path(f).expanduser().resolve() for f in folders] | |
output_wallpaper_folder = Path(output_wallpaper_folder).expanduser().resolve() | |
wallpaper_paths = [] | |
# Search for the wallpapers within the prospective folders | |
for wallpaper_name in wallpaper_list + custom_wallpaper_list: | |
for folder in folders: | |
glob_path = str(folder.joinpath(Path(wallpaper_name))) + ".*" | |
wp_path = glob.glob(glob_path) | |
if len(wp_path) > 1: | |
raise ValueError( | |
f"Found more than one match for wallpaper named: {wallpaper_name}. " | |
f"Matches are: {wp_path}" | |
) | |
# Check if a match was found and if it ended in a valid image extension | |
if wp_path and wp_path[0].split(".")[-1] in img_extensions: | |
break | |
else: | |
raise FileNotFoundError( | |
f"Couldn't find wallpaper named: {wallpaper_name} within {folders}" | |
) | |
wallpaper_paths.append(wp_path[0]) | |
os.makedirs(output_wallpaper_folder, exist_ok=True) | |
for wp_path in wallpaper_paths: | |
print(f"Copying {wp_path} to {output_wallpaper_folder} ...") | |
shutil.copy(wp_path, output_wallpaper_folder) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment