Skip to content

Instantly share code, notes, and snippets.

@bgreenlee
Last active November 4, 2024 20:50
Show Gist options
  • Save bgreenlee/df05ca05d376f6988c2abaa63ec4a765 to your computer and use it in GitHub Desktop.
Save bgreenlee/df05ca05d376f6988c2abaa63ec4a765 to your computer and use it in GitHub Desktop.
Getting the name of the current Mac Aerial screensaver/wallpaper
#!/bin/bash
# Print the name of the current Mac Aerial screensaver/wallpaper
# requires jq (brew install jq)
LANG=$(defaults read -g AppleLocale | cut -c1-2) # this is not going to work for all locales
WALLPAPERS="/Library/Application Support/com.apple.idleassetsd/Customer/entries.json"
DESCRIPTIONS="/Library/Application Support/com.apple.idleassetsd/Customer/TVIdleScreenStrings.bundle/$LANG.lproj/Localizable.nocache.strings"
# get the path of the current wallpaper video by looking at the files the WallpaperVideoExtension process has open
WPATH=$(lsof -F n -p $(pgrep WallpaperVideoExtension) | grep ".mov" | cut -c2-)
# grab the ID of the wallpaper
WID=$(basename "$WPATH" .mov)
# look up the localized string key for that wallpaper
NAME_KEY=$(jq -r ".assets[] | select(.id==\"$WID\") | .localizedNameKey" "$WALLPAPERS")
# grab the description for that key
DESC=$(plutil -extract "$NAME_KEY" raw "$DESCRIPTIONS")
echo $DESC
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment