tauri-apps / wry

Cross-platform WebView library in Rust for Tauri.
Apache License 2.0
3.39k stars 251 forks source link

Tauri color scheme detection in linux #884

Open ImUrX opened 1 year ago

ImUrX commented 1 year ago

Is your feature request related to a problem? Please describe. File browsers opened from the app dont respect the current color scheme of the DE, meanwhile opening it from Epiphany does work.

amrbashir commented 1 year ago

How are you opening these apps? provide a repro please

ImUrX commented 1 year ago

I tried opening an <input type="file">, those are the ones that don't respect the color scheme.

amrbashir commented 1 year ago

Could you give me more info about your system? OS, Desktop Environment or Window manager, and webkit2gtk version.

ImUrX commented 1 year ago
OS: EndeavourOS Linux x86_64
DE: GNOME 43.3
WebkitGTK2: 2.38.5-1
amrbashir commented 1 year ago

After hours of testing on Gnome, epiphany is always whether dark mode is enabled or not, and so is wry apps too. I think the only thing that made difference is setting the gtk theme in the gtk configuration files or through GTK_THEME env var.

I will close this for now since the behavior matches the rest of the OS.

ImUrX commented 1 year ago

I have the dark theme on through GNOME, this is not correct behavior still.

amrbashir commented 1 year ago

It didn't matter to me whether dark mode was enabled or not, the only thing that made a difference was gtk-application-prefer-dark-theme = true in gtk settings configuration file

ImUrX commented 1 year ago

OK, if i disable dark mode through the settings panel, this is reflected in Firefox for example but not in any tauri app, thats what I'm trying to say.

amrbashir commented 1 year ago

What about epiphany? what is the content of ~/.config/gtk-3.0/settings.ini?

PerBothner commented 1 year ago

I have the same problem: I create a media query:

dark_query = window.matchMedia('(prefers-color-scheme: dark)');

and set a listener:

dark_query.addEventListener('change', (e) => { ... e.matches ... })

This works on Firefox and in the gtkwebkit-based Epiphany browser. It does not work in gtkwebkit-based Wry (or Electron or Qt or the chrome browser). By "works" I mean the event fires when I change Style in Gnome Settings -> Appearance, and the appearance changes. This is on Fedora 38.

Andrew15-5 commented 9 months ago

I, too, faced this problem today (first time trying Tauri). Indeed, the content of ~/.config/gtk-3.0/settings.ini defines whether the default tauri app start with light or dark color scheme. I had this by default:

[Settings]
gtk-application-prefer-dark-theme=0

And then I changed 0 to 1. I have (custom) dark theme and it doesn't detect it.

versions ``` OS: Pop!_OS 22.04 LTS DE: GNOME 42.5 WebkitGTK2: libwebkit2gtk-4.0-37:amd64 2.40.5-0ubuntu0.22.04.1 libwebkit2gtk-4.0-dev:amd64 2.40.5-0ubuntu0.22.04.1 libwebkit2gtk-4.1-0:amd64 2.40.5-0ubuntu0.22.04.1 libwebkit2gtk-4.1-dev:amd64 2.40.5-0ubuntu0.22.04.1 ```