Created
August 8, 2019 07:27
-
-
Save TylerLeonhardt/4b87957ca96c498ad481e907a695445e to your computer and use it in GitHub Desktop.
A function to update the macOS appearance to Dark or Light mode!
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
| function Update-macOSAppearance { | |
| param( | |
| [parameter(Mandatory)] | |
| [ValidateSet('Dark', 'Light')] | |
| $Mode | |
| ) | |
| $currentMode = defaults read -globalDomain AppleInterfaceStyle | |
| $appleScriptCommand = 'osascript -e ''tell application \"System Events\" to tell appearance preferences to set dark mode to not dark mode''' | |
| if ($Mode -eq 'Light' -and ($currentMode -eq "Dark")) { | |
| iex $appleScriptCommand | |
| } | |
| if ($Mode -eq 'Dark' -and (-not $currentMode -eq "Dark")) { | |
| iex $appleScriptCommand | |
| } | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
no matter what I do, I can't seem to get rid of the "error" text:
It still works, I just can't seem to hide that text from showing up when querying
defaults... may need to switch to AppleScript for the read as well