I've found this open source project, which allows detecting the current theme: https://github.com/Dansoftowner/jSystemThemeDetector
Its dependencies are a bit complex. I tested it on Windows and Mac and it works (there are errors on Mac in the logs but it still works).
1. Download the required jars: www.b4x.com/files/jSystemThemeDetector.zip and put them in the additional libraries folder.
2. See the attached example. Don't miss the #AdditionalJars and #PackagerProperty.