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

MacOS Auto settings is treated as dark mode #1

Closed
eugene-stativka opened this issue Apr 15, 2020 · 14 comments
Closed

MacOS Auto settings is treated as dark mode #1

eugene-stativka opened this issue Apr 15, 2020 · 14 comments
Labels
bug Something isn't working

Comments

@eugene-stativka
Copy link

Thank you for your great job!
I've tried 1.1.0-pre on MacOS 10.15.4 and it seems like Auto appearance setting is treated as dark mode even if it is not a late evening and light mode is automatically set by the operating system. Can you please check?

@weisJ
Copy link
Owner

weisJ commented Apr 15, 2020

I'll have to look into it. I do not have a system with macOS installed myself. Basically the responsible code for the check is the following:

NSString *interfaceStyle = [[NSUserDefaults standardUserDefaults] stringForKey:@"AppleInterfaceStyle"];
// interfaceStyle can be nil (light mode) or "Dark" (dark mode).
BOOL isDark = [VALUE_DARK caseInsensitiveCompare:interfaceStyle] == NSOrderedSame;
BOOL switchesAutomatically = [[NSUserDefaults standardUserDefaults] boolForKey:@"AppleInterfaceStyleSwitchesAutomatically"];
if (switchesAutomatically) {
    // If switchesAutomatically == YES the roles of "Dark" and nil are changed.
    return (jboolean) !isDark;
}

If you run this on your machine does it yield the correct value?

@weisJ
Copy link
Owner

weisJ commented Apr 15, 2020

After doing some remote testing with a friends machine it seems as if the value of AppleInterfaceStyleSwitchesAutomatically can be ignored and AppleInterfaceStyle actually always represents the actual value.

@weisJ
Copy link
Owner

weisJ commented Apr 15, 2020

Could you try out if the new pre-release works as expected?

@weisJ weisJ added the bug Something isn't working label Apr 15, 2020
@eugene-stativka
Copy link
Author

Could you try out if the new pre-release works as expected?

Sure, I will do it first thing in the morning.

@eugene-stativka
Copy link
Author

In this release this issue is fixed. Thanks!

@weisJ
Copy link
Owner

weisJ commented Apr 16, 2020

I did some more research and apparently the Catalina Auto option is not that simple. If switching manually to it the properties are set correctly but if it switches by passing the time threshold the setting isn't picked up correctly.

@weisJ weisJ reopened this Apr 16, 2020
@weisJ
Copy link
Owner

weisJ commented Apr 16, 2020

I'm kind of getting conflicting information. For one there is this issue. The propsed solution is to use NSApp.effectiveAppearance. However NSApp.effectiveAppearance is always NSAppearanceAqua as the library isn't really attached to a valid application.

This issue also highlights a possible issue when powering off in dark mode and turning back in during daytime. I'll have to do more testing but as long as there is no power off involved it works.

@weisJ
Copy link
Owner

weisJ commented Apr 16, 2020

@eugene-stativka Do you experience errors between restarts/sleep mode?
However I suspect for now this issue is neglectable as I doubt a lot of people keep IDEA open between system restarts.

@eugene-stativka
Copy link
Author

@eugene-stativka Do you experience errors between restarts/sleep mode?

So far, no but maybe I haven't covered all edge cases yet. I will let you know if I notice something

@bric3
Copy link

bric3 commented Apr 17, 2020

For now the plugin behaves well.

I'm using NightOwl to control the dark mode. I've tried :

  • scheduled mode
  • manual
  • sunrise / sunset
  • closing the lid / sleep

IntelliJ 2020.1

❯ sw_vers
ProductName:	Mac OS X
ProductVersion:	10.15.4
BuildVersion:	19E287

@weisJ
Copy link
Owner

weisJ commented Apr 18, 2020

@bric3 good to know 👍 I have released the current latest pre-release (should be available in 2/3 days). If any issues arise this issue can be reopened.

@weisJ weisJ closed this as completed Apr 18, 2020
@bric3
Copy link

bric3 commented Apr 19, 2020

I've set NightOwl mode sunrise / sunset, with lid closed in-between. Looks good !

@bric3
Copy link

bric3 commented Apr 20, 2020

Actually I think I encountered a bug.

  • Use sunset mode in nightowl
  • Use the laptop after the sunset, ie in dark mode
  • Close the lid
  • Open the lid after the sunrise, the UI is light
  • I needed to test some other stuff, so I switched manually to Dark appearance, but IJ didn't respond to that change. Restarting is the only option.

Maybe I should log that in another issue.

@weisJ weisJ reopened this Apr 20, 2020
@weisJ weisJ closed this as completed Apr 20, 2020
@weisJ
Copy link
Owner

weisJ commented Apr 20, 2020

That is exactly the possible scenario that would break it I had in mind. I has to do with a weird behaviour of how auto is implemented. Generally there is the value "AppleInterfaceStyle" that is either nil or "Dark" depending of the mode. But in some scenarios their semantic is swapped.
The saver approach would be to read NSApp.effectiveAppearance but as I have mentioned before this always return the same value. I guess this has to do with the dll running outside of a valid cocoa application.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants