Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Read if Dark mode is currently used on macOS Mojave

55 views
Skip to first unread message

welle...@googlemail.com

unread,
May 10, 2019, 4:21:29 AM5/10/19
to
Hello,

macOS Mojave has introduced the Dark mode. Is it possible to read if my application is run with macOS set to Dark mode? I need to have a yes/no variable in order to perform adjustments (setting colours).

Best
Welle

Kevin Walzer

unread,
May 10, 2019, 8:26:36 AM5/10/19
to
exec defaults read -g AppleInterfaceStyle

If the answer is "Dark," it's dark -- if anything else, such as "The
domain/default pair of (kCFPreferencesAnyApplication,
AppleInterfaceStyle) does not exist", it's light.

A version of Tk is currently in development that will provide automatic
support/theme switching for dark mode in the ttk widgets, and
near-complete support in Tk widgets.

--Kevin

--
Kevin Walzer
Code by Kevin
http://www.codebykevin.com

Christopher Chavez

unread,
May 12, 2019, 2:46:49 AM5/12/19
to
On 5/10/2019 7:26 AM, Kevin Walzer wrote:
> exec defaults read -g AppleInterfaceStyle
This only reads the setting in System Preferences, and may not reflect
any per-app setting or override. I think what is being asked is how to
tell if a specific running program is using dark mode (Welle informed me
that this can depend on whether Tk is run from a script versus in an app
bundle).

One question I have on this topic: do/should <<LightAqua>> or
<<DarkAqua>> occur when a program is first launched?

Christopher A. Chavez

welle...@googlemail.com

unread,
May 12, 2019, 4:52:41 AM5/12/19
to
Hi all,

Thank you Kevin for your answer. This has helped me a lot.

Christopher, your point is interesting, I did not thought about overridings and so on. For the moment, however, Kevin solution seems to work fine, at least in standard scenarios. Since it gets the current state Dark/Light from the System Preferences, I think it is fair enough to assume that this setting will be applied to the application.

Welle

chris...@gmx.us

unread,
Jun 5, 2019, 8:11:05 AM6/5/19
to
On Friday, May 10, 2019 at 3:21:29 AM UTC-5, welle...@googlemail.com wrote:
> macOS Mojave has introduced the Dark mode. Is it possible to read if my application is run with macOS set to Dark mode? I need to have a yes/no variable in order to perform adjustments (setting colours).

I just noticed Marc Culler's solution added to core-8-6-branch a couple months ago, which is described in macosx/README, and mentioned on the Wiki: https://wiki.tcl-lang.org/page/Tk+differences+on+Mac+OS+X "


To get the current appearance of a window as a boolean value:

tk::unsupported::MacWindowStyle isdark window


To get/set the appearance as "aqua"/"darkaqua"/"auto":

tk::unsupported::MacWindowStyle appearance window ?newAppearance?
0 new messages