Monday, August 25, 2014

Quick tip: Detect OS X Yosemite dark mode from FileMaker

How to detect if OS X Yosemite is in "Dark Mode" from FileMaker?

Dark mode is stored in a defaults entry:  AppleInterfaceStyle
It's either "Dark" or no value.

So we just basically check if we get an error if we try to read this value.
If we get a value, we are in "Dark mode", else we're using "Normal mode".

Basic steps:

If [Abs (Get(SystemPlatform)) = 1]   //Running on OS X
    Perform AppleScript["do shell script "defaults read -g AppleInterfaceStyle""]  -  Native
      If [Get(LastError) = 0]
        Show Custom Dialog ["Dark mode!"]
      Else
        Show Custom Dialog["Normal mode!"]
      End if
End if

That's all.
You may use this to switch to a different themed layout, or to change your background color.