Last active
September 15, 2023 05:36
-
-
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.
This file contains 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
#!/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