Last active
November 4, 2024 20:50
-
-
Save bgreenlee/df05ca05d376f6988c2abaa63ec4a765 to your computer and use it in GitHub Desktop.
Getting the name of the current Mac Aerial screensaver/wallpaper
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
#!/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