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

Demo app does not work on macOS Big Sur 11.4 #16

Open
nsmoker opened this issue Jun 21, 2021 · 2 comments
Open

Demo app does not work on macOS Big Sur 11.4 #16

nsmoker opened this issue Jun 21, 2021 · 2 comments

Comments

@nsmoker
Copy link

nsmoker commented Jun 21, 2021

When running OsThemeDetectorDemo on Big Sur 11.4, changing the OS theme does not result in any printouts like it should. The isDark function can correctly identify whether or not the system is in dark mode, but the listener is not called when the OS theme is changed.

The value of OsThemeDetector.getDetector().getClass().getName() is com.jthemedetecor.MacOSThemeDetector, so it would appear that this is not an issue of the detector implementation being determined incorrectly.

The graphical demo app does work.

@nsmoker nsmoker changed the title Demo app does not work on macOS Big Sur Demo app does not work on macOS Big Sur 11.4 Jun 21, 2021
@Dansoftowner
Copy link
Owner

Thanks for reporting the issue!
Does it work if you initialize the OsThemeDetector instance on a background thread?
Like this:

ExecutorService executor = Executors.newSingleThreadExecutor();
final OsThemeDetector detector = executor.submit(OsThemeDetector::getDetector).get();
...

@nsmoker
Copy link
Author

nsmoker commented Jun 25, 2021

Hey, sorry for the delay. Unfortunately, using a background thread doesn't appear to change anything. Could be related to this SO thread. Based on some tests I did with my own wrapper around the Obj-C runtimes and Foundation, it seems like Mac will only send you InterfaceStyleChanged notifications if you have already have an NSApp running somewhere, which makes listening for those notifications useless and breaks the theme detection for CLI tools.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants