NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
16.45k stars 12.95k forks source link

gtk4 dark theme broken since upgrade to 23.11 #274554

Open merspieler opened 6 months ago

merspieler commented 6 months ago

Describe the bug

Since the upgrade to 23.11, gtk4 apps no longer respect the set dark mode.

Steps To Reproduce

Steps to reproduce the behavior:

  1. set dark mode for gtk4 via nix-shell -p glib --run "gsettings set org.gnome.desktop.interface gtk-theme 'Adwaita-dark'"
  2. launch any gtk4 app via Dmenu or terminal
  3. it's not in dark mode

Only way I got it into using dark mode was like this: GTK_THEME=Adwaita-dark <program> but that's not feasible when using dmenu

Expected behavior

All gtk4 apps are in dark mode

Additional context

Add any other context about the problem here.

In case it makes a difference, I'm running i3wm under X.org.

Metadata

Please run nix-shell -p nix-info --run "nix-info -m" and paste the result.

[user@system:~]$ nix-shell -p nix-info --run "nix-info -m"
 - system: `"x86_64-linux"`
 - host os: `Linux 6.1.67, NixOS, 23.11 (Tapir), 23.11.1779.cf28ee258fd5`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.18.1`
 - channels(root): `"nixos-23.11, nixos-unstable"`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`

Add a :+1: reaction to issues you find important.

alesya-h commented 5 months ago

It's not just gtk4. For me it's mostly gtk3 apps with some exceptions, whereas gtk4 apps all work normally. I've tested the following apps: GTK3 (Tilix :x: , Terminator :x: , Meld :x:, Gnome Disks :green_circle: ) and GTK4 (BlackBox :green_circle: , Console :green_circle: , Gedit :green_circle: , Blanket :green_circle:). For apps that show in white style gtk inspector shows an unset theme, but setting it and/or toggling "Dark Variant" doesn't change anything: image image

mannp commented 4 months ago

For me, both gtk3 and gtk4 settings.ini had the following settings;

[Settings]
gtk-icon-theme-name=Adwaita
gtk-theme-name=Adwaita-dark
gtk-application-prefer-dark-theme=0

changing to;

[Settings]
gtk-icon-theme-name=Adwaita
gtk-theme-name=Adwaita
gtk-application-prefer-dark-theme=1

Made things dark again :)

merspieler commented 4 months ago

already had prefer dark theme, added the others as well now, programs are still white

mannp commented 4 months ago

Do you have gnome tweaks installed by any chance?

gtk-theme-name=Adwaita-dark, should be gtk-theme-name=Adwaita for me, will update.

alesya-h commented 4 months ago

@mannp adding those lines didn't fix it. To me it seems that the problem is with apps not being able to find Awaita Dark theme (or any theme at all, see inspector screenshots above)

mannp commented 4 months ago

@mannp adding those lines didn't fix it. To me it seems that the problem is with apps not being able to find Awaita Dark theme (or any theme at all, see inspector screenshots above)

Sure, I don't use inspector, but within gnome tweaks the adwaita dark theme is not specified separately now, it's just Adwaita for me.

jtojnar commented 4 months ago

Only way I got it into using dark mode was like this: GTK_THEME=Adwaita-dark <program> but that's not feasible when using dmenu

This sounds like OP is using libadwaita-based GTK 4 apps, where changing the gtk-theme GSettings key (from org.gnome.desktop.interface schema) does not work.


The rest of you are are probably encountering unrelated issue triggered by https://github.com/NixOS/nixpkgs/pull/278941.

In short, Adwaita-Dark should not be used these days since it is unmaintained. The aforementioned PR removes it from the default installation.

You should instead use the Adwaita theme shipped with GTK 3, which has dark theme built in (if you set gtk-application-prefer-dark-theme=1 in GTK 3 config).

For GTK 4 apps not using libadwaita, the theme is called Default, gtk-application-prefer-dark-theme=1 (in GTK 4 config) should work there as well.

For libadwaita-based GTK 4 apps, you need to set the color-scheme GSettings key (from org.gnome.desktop.interface schema) to 'prefer-dark'.

merspieler commented 4 months ago

tried all of those options, kdenlive for example... white

jtojnar commented 4 months ago

That is not a GTK app so no idea how it works there.

merspieler commented 4 months ago

wait do I have another problem here? cause that broke together in the same update with all the GTK stuff...

jtojnar commented 4 months ago

It might be that Kdenlive uses some kind of heuristic (e.g. checking if theme name ends with dark, or parsing the GTK theme to discover the background and not knowing about prefer-dark-theme setting).

You will probably be best off asking its maintainers.

dawidd6 commented 1 month ago

Only way I got it into using dark mode was like this: GTK_THEME=Adwaita-dark <program> but that's not feasible when using dmenu

This sounds like OP is using libadwaita-based GTK 4 apps, where changing the gtk-theme GSettings key (from org.gnome.desktop.interface schema) does not work.

The rest of you are are probably encountering unrelated issue triggered by #278941.

In short, Adwaita-Dark should not be used these days since it is unmaintained. The aforementioned PR removes it from the default installation.

You should instead use the Adwaita theme shipped with GTK 3, which has dark theme built in (if you set gtk-application-prefer-dark-theme=1 in GTK 3 config).

For GTK 4 apps not using libadwaita, the theme is called Default, gtk-application-prefer-dark-theme=1 (in GTK 4 config) should work there as well.

For libadwaita-based GTK 4 apps, you need to set the color-scheme GSettings key (from org.gnome.desktop.interface schema) to 'prefer-dark'.

This should be put in 24.05 release notes. I've just run into this problem and your post really helped. Thanks!

nixos-discourse commented 1 month ago

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/nixos-24-05-released/46279/9

jtojnar commented 1 month ago

We mentioned the Adwaita-Dark removal in https://github.com/NixOS/nixpkgs/commit/86cc033bf9a44225c8caadb2e2ec6f02feee02eb but for some reason it disappeared from the history. https://github.com/NixOS/nixpkgs/pull/316270 adds it back.

auroraanna commented 3 weeks ago

when i try setting anything via gsettings i get No schemas installed.

jtojnar commented 3 weeks ago

We intentionally do not make schemas globally available. You need to run gsettings with XDG_DATA_DIRS environment variable to set to schema paths you need.

gepbird commented 1 week ago

For libadwaita-based GTK 4 apps, you need to set the color-scheme GSettings key (from org.gnome.desktop.interface schema) to 'prefer-dark'.

Any idea why this doesn't work for me? I tested it with nautilus on dwm window manager, using the latest nixos-unstable branch.

2024-06-23_20-55

Currently I'm using an ugly workaround where I link adw-gtk3's dark gtk.css to gtk4 config, but I'd like to remove it and properly set dark theme for gtk4 apps.