frewsxcv / rust-dark-light

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

Linux support? #1

Closed lemunozm closed 2 years ago

lemunozm commented 3 years ago

Hi! are there any ideas for Linux support?

frewsxcv commented 3 years ago

I don't have a Linux machine so I won't be able to help much, but I'd accept a PR if someone opened one. What is the story for dark mode on Linux? I assume it depends which desktop environment you use

lemunozm commented 3 years ago

Yeah, it depends of the desktop environment. For example for gnome (one of most used), I think it could be reached using gsettings (gtk-rs crate).

edfloreshz commented 3 years ago

I can help, I already implemented code for KDE Plasma.

Seirdy commented 2 years ago

The cross-platform way to do this on Freedesktop-complaint platforms will be through the color-scheme key of xdg-desktop-portal's org.freedesktop.appearance interface. This will be implemented in GNOME 42 and will probably be implemented across Flatpak with time; libadwaita apps should already support it if available. As this is a Freedesktop standard, I imagine that KDE will follow this path too.

If you want to test this out and have xdg-desktop-portal-gnome and/or xdg-desktop-portal-gtk installed, you should be able to test it out if you install the color-scheme simulator, a portal that provides a shim interface.

Seirdy commented 2 years ago

Turns out that KDE already merged support into xdg-desktop-portal-kde two weeks ago; see MR 52.

So using this interface should grant across the GNOME and KDE desktop portals. By extension, many Flatpak apps will also be supported.

frewsxcv commented 2 years ago

https://github.com/frewsxcv/rust-dark-light/pull/4