Created
March 29, 2019 23:05
-
-
Save AndrewWCarson/fdd324c4a5ccaf7e5d3e25d8f9959bd0 to your computer and use it in GitHub Desktop.
Toggle between Light & Dark mode.
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/bin/python | |
# | |
# This toggles the macOS appearance from Light mode to Dark mode and vice | |
# versa. | |
# | |
# Big thanks to Mike Lynn for his help. Esp. this gist: | |
# https://gist.github.com/pudquick/ba235b7e90aafb9986158697a457a0d0 | |
# | |
# Still looking for the function to perfectly simulate changing themes via the | |
# System Prefs UI. iStat menus seems to not be getting the hint. | |
import platform | |
from Foundation import NSBundle | |
vers, _, _ = platform.mac_ver() | |
if float(vers.split('.')[1]) != 14: | |
exit | |
else: | |
appearanceBundle = NSBundle.bundleWithPath_("/System/Library/PreferencePanes/Appearance.prefPane") | |
appearanceShared = appearanceBundle.classNamed_('AppearanceShared') | |
app = appearanceShared.sharedAppearanceAccess() | |
if app.theme() == 1: | |
app.setTheme_(0) | |
else: | |
app.setTheme_(1) |
Doesn't notify apps when run from a different user context. Even sudo -u "$username
from the root user doesn't send the notification to apps.
Yeah. This is a decent start, but needs some fluff for EUX.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I don't know of a way to enforce themes, yet. Hence, digging under to hood to get some additional access to them.
Using these methods and some kind of Restrictions profile payload to lock down System Prefs may be the best?