Is there a setting that can be read / polled to determine if the global Ubuntu dark mode is enabled or not by the user. I’m writing an app and would like to honour the user’s preference for my UI.
Asked
Active
Viewed 1,631 times
5
1 Answers
0
This is not a fancy solution, but you can read the font color css value of e.g. some label. For dark themes this will (probably) be white(ish) and otherwise black. Same should be possible for backgroud-color and so on.
Python example:
tmp = self.label.get_style_context().get_color(Gtk.StateFlags.NORMAL)
textcolor = (tmp.red, tmp.green, tmp.blue, tmp.alpha)

jl005
- 173
gsettings get org.gnome.desktop.interface gtk-theme
if this returns 'Yaru-dark' then it is dark mode.. – PRATAP Jul 23 '20 at 11:30-dark
to dark themes? I see the same seems to be true for Adwaita. – Garry Pettet Jul 23 '20 at 12:43-dark
. It can be any name.. – PRATAP Jul 23 '20 at 13:11