-
-
Save ksbeattie/35b27738e1034658b8d3e16c5cce9223 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 | |
| # From: https://gist.github.com/bgreenlee, extended to support multiple monitors and Tahoe MacOS | |
| # 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="$HOME/Library/Application Support/com.apple.wallpaper/aerials/manifest/entries.json" | |
| DESCRIPTIONS="$HOME/Library/Application Support/com.apple.wallpaper/aerials/manifest/TVIdleScreenStrings.bundle/$LANG.lproj/Localizable.nocac\ | |
| he.strings" | |
| # Get the path of the current wallpaper videos by looking at the .mov files the WallpaperAerial process has open | |
| WPATH=$(lsof -F n -p $(pgrep WallpaperAerial) | grep ".mov" | cut -d / -f 9) | |
| for wp in ${WPATH}; do | |
| # grab the ID of the wallpaper | |
| WID=$(basename "$wp" .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 | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment