macOS “Big Sur” Detect dark menu-bar/system tray

隐身守侯 提交于 2020-07-30 20:01:53

问题


Starting with macOS (10.16 "Beta"/11.0) "Big Sur", the menu-bar and system tray no longer honor the Desktop dark-mode preference, making it difficult to properly theme a system tray icon for this Desktop.

Previously, using a shell command default read, the dark mode could be detected:

defaults read -g AppleInterfaceStyle
# "Dark"

This still works great for detecting the Window theme, but it does not work for the menu-bar and system tray theme.

Since this area seems to be driven by the wallpaper brightness/whiteness/luminosity, how do we detect a dark system tray?

How to detect this in (e.g.) Objective-C/C++? Any solution is welcome, as most can be adapted.

Question also posted to Apple Developer forums: https://developer.apple.com/forums/thread/652540

Qt5.6 has a feature called setIsMask(...) which allows the OS to handle this automatically. This is effectively an alias for NSImage::setTemplate:Yes

More references to macOS "Dark Mode":

  • How to detect if OS X is in dark mode?
  • MenuBar Icon for Dark Mode on OS X in Java

AdoptOpenJDK upstream bug report:

  • https://github.com/AdoptOpenJDK/openjdk-support/issues/146

Keywords: NSStatusBar, Menu Bar Extras

来源:https://stackoverflow.com/questions/62685948/macos-big-sur-detect-dark-menu-bar-system-tray

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!