sudipshil9862 / fonts-compare

fonts rendering and comparing
GNU General Public License v2.0
5 stars 2 forks source link

use libadwaita to detect system darkmode #52

Closed juhp closed 3 months ago

juhp commented 3 months ago

Should follow system light/dark mode and provide better style/sizing hopefully.

sudipshil9862 commented 3 months ago

I checked with commands, if we can tell that the os is in dark mode or not, but

gsettings get org.gnome.desktop.interface gtk-theme
'Adwaita'
gsettings get org.gnome.desktop.interface gtk-theme
'Adwaita'

both in dark and NOT dark cases it is giving Adwaita theme

Is there any other way to tell if it's in dark mode ?

sudipshil9862 commented 3 months ago

what if we just keep this in light mode when initialize and let users decide what they need the dark mode in app or not. If they need dark mode in the app, they can just easily turn on the DARK THEME just enabling the checkbox in hamburger icon.

But there is definitely a way to check whether the system os is in dark mode or not !!

sudipshil9862 commented 3 months ago

just for temporary code and it wan't able to check whether the system is in dark mode

settings = Gtk.Settings.get_default()
preferred_theme_name = settings.get_property('gtk-theme-name')
is_dark_mode = preferred_theme_name.endswith('-dark')
if is_dark_mode:
     self.darktheme_checkbox.set_active(True)
     settings = Gtk.Settings.get_default()
     settings.set_property("gtk-application-prefer-dark-theme", True)
juhp commented 3 months ago

https://gnome.pages.gitlab.gnome.org/libadwaita/doc/1-latest/

sudipshil9862 commented 3 months ago

https://gnome.pages.gitlab.gnome.org/libadwaita/doc/1-latest/method.StyleManager.get_dark.html