frewsxcv / rust-dark-light

Rust crate to detect if dark mode or light mode is enabled
https://crates.io/crates/dark-light
73 stars 12 forks source link

Gnome only returns as light theme #36

Open SO9010 opened 2 months ago

SO9010 commented 2 months ago

When using this crate on gnome, arch, it only returns white as the system preference. I have tried KDE Plasma and that works fine.

nixigaj commented 6 days ago

I have not investigated any code, but i think this is because it does not read the xdg-desktop-portal dark mode property. Instead it reads the metadata of the current GTK 3/4 theme if it is light or dark (but i could be completely wrong on this).

Anyways. A workaround is to install the Night Theme Switcher extension and enable the "Switch GTK theme" option. You do not necessarily have to select any GTK theme, it just starts magically working.

Screenshot from 2024-06-25 14-33-36

Screenshot from 2024-06-25 14-35-02

Edit:

It seems that the notify API recently merged does work properly with the notify example without having to do this workaround, but it does not with the detect example, so there seems to be two different methods used for detecting and notifying, where the detect API should probably use the same code that the notify API uses.