Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add APIs to support MacOS Mojave dark modes #6819

Closed
gpetrov opened this issue Oct 3, 2018 · 6 comments
Closed

Add APIs to support MacOS Mojave dark modes #6819

gpetrov opened this issue Oct 3, 2018 · 6 comments
Labels

Comments

@gpetrov
Copy link

gpetrov commented Oct 3, 2018

Please add API to detect system macOS Mojave dark modes, just like in Electron

electron/electron@0d2a0c7#diff-8330cc91b59f45f220fe480486215c97

It might be useful to other the other System Preferences API as well @rogerwang

https://github.com/electron/electron/commits/master/docs/api/system-preferences.md

@theDevelopper
Copy link

dark mode support would really be great. We need an event that fires on appearance change and a way to fetch the current appearance.

@razor-4eg
Copy link

@razor-4eg
Copy link

razor-4eg commented Oct 18, 2018

Or you just use macOS bash command 'defaults' to read this:
defaults read -g AppleInterfaceStyle
if it dark it will return a string: "Dark"

@theDevelopper
Copy link

I tried the node-dark-mode already. It does nothing on my Mojave machine. And using the Shell won't solve the issue of changing the Appearance later on as there is no event handler listening to changes.
Also neither solve high contrast themes which are also available.

@razor-4eg
Copy link

razor-4eg commented Oct 19, 2018

Ok another dirty solution, because I don't believe that API happens in near time))

  • we know that macOS store it's settings in a file right after user change something.
  • we can watch that file and do something when it changed
  • we need to figure out the settings key names for dark mode in Mojave and for high contrast themes
  • we can check this values when settings file was updated

File we need: ~/Library/Preferences/.GlobalPreferences.plist

something like this:

fs.watchFile('/Users/<user>/Library/Preferences/.GlobalPreferences.plist', async (curr, prev) => {
	// check settings values by shell command 'defaults read -g AppleInterfaceStyle'
});

@stale
Copy link

stale bot commented Oct 22, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Oct 22, 2019
@stale stale bot closed this as completed Oct 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants