Change theme based on daytime

Hi everyone,

is it possible to have grafana change the theme (dark and light) based on the daytime?
On smartphones and Windows this is often called night or dark mode.

Thought about building a crontab which changes the default theme setting in grafana.ini but changing, and restarting grafana did not actualy change the theme, just the default theme (as the option says, duh).

any idea how to do this? the dark theme is sometimes not really eye-friendly especially at daytimes but the light seem isn’t nice to look at in a dark room.

Hi @schreibmirnix

Please take a look at Grafana API.
This may help you https://grafana.com/docs/grafana/latest/http_api/preferences/

Example updates “theme” is user settings:

Regards,
V.

Thanks, that works!

curl -X PUT -H “Authorization: Bearer API-KEY-HERE” -H “Accept: application/json” -H “Content-Type: application/json” -d ‘{“theme”:“light”}’ http://localhost/api/user/preferences

1 Like

Great to hear @schreibmirnix :slight_smile: