Have Mojave's Dark Mode switch PyCharm theme to Darcula Is there a way to trigger 3rd party apps to change to dark themes when Dark Mode is turned on in macOS Mojave?

Specifically, can I have PyCharm switch theme automatically to Darcula when I turn on Dark Mode?

LightsOff shows a list of all apps to theoretically selectively choose Light/Dark Mode for, but it has no effect on PyCharm.
This is unfortunate especially since PyCharm is shown on the LightsOff homepage as if LightsOff can control its theme.
Chrome, MATLAB and SourceTree are also 3rd party apps with a dark theme that show no effect. The only app I use which switched to a dark theme with LightsOff is Things.
I have come up with a (hacky) way to change themes in JetBrains editors using bash and AppleScript. An example for PyCharm would be something like:

#!/bin/bash

# Switch macOS dark mode on and off
osascript -e '
    tell application "System Events"
        tell appearance preferences
            set dark mode to not dark mode
        end tell
    end tell
'

# Change PyCharm theme

# Assumes default key mappings
# Switch to dark theme if macOS dark mode is on
# 2&gt;/dev/null to suppress error if macOS dark mode is off
if defaults read -g AppleInterfaceStyle 2&gt;/dev/null | grep -q "Dark"; then
    osascript -e '
        if application "PyCharm" is running then
            -- switch focus to PyCharm
            tell application "PyCharm" to activate
            tell application "System Events"
                -- open Quick Switch Theme menu
                keystroke "`" using {control down}
                -- Select Look and Feel
                keystroke "5"
                delay 0.4
                -- Select Darcula
                keystroke "2"
            end tell
        end if
        '
# Switch to light theme if macOS dark mode is off
else
    osascript -e '
        if application "PyCharm" is running then
          tell application "PyCharm" to activate
            tell application "System Events"
                keystroke "`" using {control down}
                keystroke "5"
                delay 0.4
                keystroke "1"
            end tell
        end if
        '
fi


I actually use it as a part of a larger script but the code above should work fine for PyCharm only (or any other JetBrains IDE, just replace application name). If you experience issues, I would suggest increasing/introducing delays between keystrokes like the delay 0.4 in the code above.