You can do it with a custom template function.
Code:
def evaluate(self, formatter, kwargs, mi, locals):
from qt.core import QApplication
if QApplication.instance().is_dark_theme:
return 1
else:
return ''
function name: is_dark_theme
arg count: -1
Code:
program:
is_dark_theme()