macOS disable/enable DarkMode for specific Apps
I’ve been disappointed with macOS for quite some time. I’m still using Mac daily because I still need to deal with iOS and Mac development. I’ll not go into all problems in this post, but DarkMode, for example, Console App and TextEdit, every time I need to open a log file using Console or deal with some text file using TextEdit, It’s a pain, in special TextEdit when the file is RTF (Rich Text Format).
Unless the Developer allows you to choose the mode you want to use, there are no settings on macOS that let you change it for specific Apps. Well, since there is no official solution from Apple to enable/disable DarkMode for specific Apps, there is a small trick we can do to enforce the mode we want to use for specific Apps. To be able to achieve this goal, we are going to use a terminal command on macOS called defaults.
defaults
The defaults command on macOS is powerful. It allows you to modify some hidden user settings on specific Apps or macOS. If you wish to know more about defaults check this guide macOS Defaults.
Identify the bundle id of the Application
The first step is to identify the bundle id of the application we want to enforce the mode. To do that, we need to run the following command in the Terminal.
osascript -e 'id of app "TextEdit"'
After identifying the app, we need to change the key NSRequiresAquaSystemAppearance to enforce the mode we want to use, Yes for LightMode and No for LightMode.
Enforce LightMode
defaults write com.apple.TextEdit NSRequiresAquaSystemAppearance -bool Yes
Enforce DarkMode
defaults write com.apple.TextEdit NSRequiresAquaSystemAppearance -bool No
Use system defaults
If you want to restore the system default for the App, you need to delete the NSRequiresAquaSystemAppearance key with the following command.
defaults delete com.apple.TextEdit NSRequiresAquaSystemAppearance
References
That’s all, and I hope this can be useful for someone else as well.
Thank you