wry icon indicating copy to clipboard operation
wry copied to clipboard

Tauri color scheme detection in linux

Open ImUrX opened this issue 2 years ago • 11 comments

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.

ImUrX avatar Feb 15 '23 05:02 ImUrX

How are you opening these apps? provide a repro please

amrbashir avatar Feb 16 '23 13:02 amrbashir

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

ImUrX avatar Feb 16 '23 18:02 ImUrX

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

amrbashir avatar Mar 07 '23 13:03 amrbashir

OS: EndeavourOS Linux x86_64
DE: GNOME 43.3
WebkitGTK2: 2.38.5-1

ImUrX avatar Mar 07 '23 18:03 ImUrX

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.

amrbashir avatar Mar 08 '23 18:03 amrbashir

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

ImUrX avatar Mar 08 '23 18:03 ImUrX

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

amrbashir avatar Mar 08 '23 18:03 amrbashir

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.

ImUrX avatar Mar 08 '23 18:03 ImUrX

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

amrbashir avatar Mar 08 '23 18:03 amrbashir

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.

PerBothner avatar May 23 '23 18:05 PerBothner

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

Andrew15-5 avatar Oct 05 '23 21:10 Andrew15-5