Here is a script to detect current Appearance name and return true/false.
This script works fine with Script Editor or Script Debugger. But can not detect with AppleScript application project on Xcode.
use AppleScript version "2.4" -- Yosemite (10.10) or later
use framework "Foundation"
use scripting additions
set apRes to retLightOrDark() of me
on retLightOrDark()
set pInfo to (current application's NSProcessInfo's processInfo()'s operatingSystemVersion()) as record
set aVer to (minorVersion of pInfo) as integer
if aVer = 13 then
try
set sRes to (do shell script "defaults read -g AppleInterfaceStyle")
return (sRes = "Dark") as boolean
on error
return false
end try
else if aVer > 13 then
--macOS 10.14 or later
set curAppearance to ((current application's NSAppearance)'s currentAppearance()'s |name|()) as string
if curAppearance = "NSAppearanceNameDarkAqua" then
return true
else
return false
end if
else
return false
end if
end retLightOrDark
use AppleScript version "2.4" -- Yosemite (10.10) or later
use framework "Foundation"
use scripting additions
set apRes to retLightOrDark() of me
--> true (Dark), false (Light)
on retLightOrDark()
try
set sRes to (do shell script "defaults read -g AppleInterfaceStyle")
return (sRes = "Dark") as boolean
on error
return false
end try
end retLightOrDark