title: macOS "Big Sur" Detect dark menu-bar/system tray
body: <p>Starting with macOS (10.16 &quot;Beta&quot;/11.0) &quot;Big Sur&quot;, 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.</p>
  <p>Previously, using a shell command <code>default read</code>, the dark mode could be detected:</p>
  <pre><code>defaults read -g AppleInterfaceStyle
  # &quot;Dark&quot;
  </code></pre>
  <p>This still works great for detecting the Window theme, but it does not work for the menu-bar and system tray theme.</p>
  <p>Since this area seems to be driven by the wallpaper brightness/whiteness/luminosity, how do we detect a dark system tray?</p>
  <p><a href="https://i.stack.imgur.com/sANZm.gif" rel="noreferrer"><img src="https://i.stack.imgur.com/sANZm.gif" alt="n" /></a></p>
  <p>How to detect this in (e.g.) Objective-C/C++?  Any solution is welcome, as most can be adapted.</p>
  <p>Question also posted to Apple Developer forums: <a href="https://developer.apple.com/forums/thread/652540" rel="noreferrer">https://developer.apple.com/forums/thread/652540</a></p>
  <p>Qt5.6 has a feature called <a href="https://github.com/qt/qtbase/blob/471e4fcb226c4523efe93b1bdaf0db026495da94/src/gui/image/qicon.cpp#L1341-L1355" rel="noreferrer"><code>setIsMask(...)</code></a> which allows the OS to handle this automatically.  This is effectively an alias for <a href="https://stackoverflow.com/a/25498025/3196753"><code>NSImage::setTemplate:Yes</code></a></p>
  <p>More references to macOS &quot;Dark Mode&quot;:</p>
  <ul>
  <li><a href="https://stackoverflow.com/questions/25207077">How to detect if OS X is in dark mode?</a></li>
  <li><a href="https://stackoverflow.com/questions/33477294">MenuBar Icon for Dark Mode on OS X in Java</a></li>
  </ul>
  <p>AdoptOpenJDK upstream bug report:</p>
  <ul>
  <li><a href="https://github.com/AdoptOpenJDK/openjdk-support/issues/146" rel="noreferrer">https://github.com/AdoptOpenJDK/openjdk-support/issues/146</a></li>
  </ul>
  <p>Keywords: <code>NSStatusBar</code>, <code>Menu Bar Extras</code></p>