Switch UI theme programatically

In CLion, I have two UI themes to choose from: Default and Darcula. I like Default during day, Darcula at night.

Is there any way to switch between themes programatically, from external script or an IDE plugin?
Ideally, the change should be triggered by external event, for example depending on light sensor data or current time.

On Mac, I can run the following Apple Script:

activate application "CLion"

tell application "System Events"
keystroke "," using command down
delay 1.0
key code 115 -- home
key code 124 -- right
key code 125 -- down (Appearance)
key code 48 -- tab (Theme)
key code 125 -- down (drop down)
key code 125 -- down (Darkula)
key code 36 -- enter
key code 36 -- enter
end tell

It works, but the keypresses may not be registered due to various delays. Also I would like not to see the Preferences dialog at all, just switch the theme.

I've also played with LivePlugin, found UIManager.setLookAndFeel(), but that seems to be very low level and does not affect the Theme selector at all.

Is there any better, more reliable solution?

0
2 comments

You could try to use Day And Night plugin, is you still haven't found solution for your problem :) 

https://plugins.jetbrains.com/plugin/12006-day-and-night 

0

Thank you, I'll try it.

The solution I've found is the Quick Switch Scheme menu, which can be controlled via keyboard.

0

Please sign in to leave a comment.