Setting Nautiilus GTK Theme

I’m using NixOS with GNOME, and I use Nautilus as File Manager.

I set Tokyo Night Dark GTK theme (tokyo-night-gtk package) and it works well on GNOME windows like GNOME Tweaks and I tested it also on Mate and Cinnamon DEs and this GTK theme works.

I set this theme by:

  home-manager.users.${username} = { pkgs, ...}: {
    gtk = {
      enable = true;
      gtk3.extraConfig.gtk-decoration-layout = "menu:";
      theme = {
        name = "Tokyonight-Dark-B";
        package = pkgs.tokyo-night-gtk;
      };
      iconTheme = {
        name = "Tokyonight-Dark";
      };
      cursorTheme = {
        name = gtkCursorTheme;
        package = pkgs.bibata-cursors;
      };
    };

The problem is that this theme is not applied on Nautilus window that remains a light theme (I guess Adwaita).

How can I apply Nautilus GTK theme?

1 Like

Nautilus is a libadwaita apps and those do not support theming, see Why and how libadwaita prevents theming? - #31 by bragefuglseth - Desktop - GNOME Discourse

If you want Nautilus to use a dark color scheme, you can change the color-scheme key in org.gnome.desktop.interface GSettings schema to 'prefer-dark'.

If you do not care about “voiding the warranty”, then there is the option of using the third-party Gradience app to customize Adwaita, which modifies ~/.config/gtk-4.0/gtk.css. And there is also the GTK_THEME environment variable that can force change the theme but that is meant for debugging.

Mmm but on my Arch Linux I set the Nautilus GTK theme according to the set theme. My doubt is: is Nautilus GTK-4? If so, the only manner to manage it is to create a gtk-4.0/gtk.css file?

How did you do it on Arch then?

Yes, Nautilus is using GTK 4 but also libadwaita, so gtk-theme setting from org.gnome.desktop.interface GSettings schema will be ignored. Only the options mentioned above are available.

I followed a solution from a Nix discord server from a user suggested me to set:

home.sessionVariables.GTK_THEME = "Tokyonight-Dark-B";

and after reboot, it works!

Yes, that is the debugging environment variable approach I mentioned. Just note that it is unsupported and if some app gets broken, you should report the issue to the theme developer, not the app developer.

1 Like

Instead of using the (debugging) env var, you should symlink the GTK4 folder. Example using home-manager:

xdg.configFile = {
  "gtk-4.0/assets".source = "${config.gtk.theme.package}/share/themes/${config.gtk.theme.name}/gtk-4.0/assets";
  "gtk-4.0/gtk.css".source = "${config.gtk.theme.package}/share/themes/${config.gtk.theme.name}/gtk-4.0/gtk.css";
  "gtk-4.0/gtk-dark.css".source = "${config.gtk.theme.package}/share/themes/${config.gtk.theme.name}/gtk-4.0/gtk-dark.css";
};

With this solution you won’t need to reboot to apply your gtk themes :slight_smile: