Skip to content

Instantly share code, notes, and snippets.

@macprince
Last active September 15, 2023 05:36
Show Gist options
  • Save macprince/b489ace5da1f1851a6fbe5f8eb10672d to your computer and use it in GitHub Desktop.
Save macprince/b489ace5da1f1851a6fbe5f8eb10672d to your computer and use it in GitHub Desktop.
This script will dynamically override the settings for XCreds to set the login screen wallpaper on your M1 iMacs to the proper color "hello" wallpaper for that color of iMac.
#!/usr/local/bin/managed_python3
import re
import plistlib
import subprocess
colors = {
"1": "Grey",
"3": "Yellow",
"4": "Green",
"5": "Blue",
"6": "Red",
"7": "Purple",
"8": "Orange"
}
cmd = "/usr/libexec/remotectl dumpstate"
regexp = re.compile('(?<=DeviceEnclosureColor\s=>\s)\d')
result = subprocess.run(cmd, shell=True, capture_output=True, text=True)
color_id = regexp.search(result.stdout).group()
color = colors[color_id]
wallpaperpath=f"/System/Library/Desktop Pictures/hello {color}.heic"
output_pl = dict(
loginWindowBackgroundImageURL = f"file://{wallpaperpath}"
)
print(plistlib.dumps(output_pl).decode())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment