Struggling to configure GTk/QT theme on laptop

We probably need to enforce theme by setting variables in sway configuration or somewhere else.
Snippet from hyprland.conf:

# Some default env vars.
env = XCURSOR_SIZE,16
#env = QT_QPA_PLATFORMTHEME,qt5ct # change to qt6ct if you have that
#env =  GTK2_RC_FILES,/home/USER/.config/gtk-2.0/gtkrc
env =  QT_QPA_PLATFORMTHEME,gtk2
env =  QT_STYLE_OVERRIDE,gtk2

Icons are working in pcmanfm-qt with some variables.

1 Like

After posting my reply the icons disappeared from my pcmanfm-qt :sweat_smile:

Thankfully the issue was easily fixed from the settings, just go to Edit > Preferences > User Interface and choose Papirus-Dark as your icon theme.

Don’t know why this happened now, but I remember this happening to me before in other distros.

systemd.user.sessionVariables was the only way for qt5ct to read QT_QPA_PLATFORMTHEME for me. I tried:

  • environment.sessionVariables
  • environment.variables
  • home.sessionVariables

But those didn’t work.

Also, this was only necessary when using nixpkgs.config.qt as I didn’t have to manually set any variable when just using qt. This is on Gnome, though, so it might be necessary for other DE or WM.

Oh, that’s super helpful!

Only reason I was using Breeze+catppuccin is history xD I’m now on [almost] full catppuccin thanks to you :smiley:

I got no icons on pcmanfm-qt and pavucontrol-qt. Everything else looks fine.

Here’s my home.nix:

# Theme for graphical apps
{ machine, lib, pkgs, ... }:
{
  home.packages = with pkgs; [
    (catppuccin-kvantum.override {
      accent = "Blue";
      variant = "Mocha";
    })
    libsForQt5.qtstyleplugin-kvantum
    papirus-folders
  ];

  # Cursor setup
  home.pointerCursor = {
    name = "Catppuccin-Mocha-Lavender-Cursors";
    package = pkgs.catppuccin-cursors.mochaLavender;
    gtk.enable = true;
    size = machine.seat.cursorSize;
  };

  # GTK Setup
  gtk = {
    enable = true;
    theme = {
      name = "Catppuccin-Mocha-Standard-Blue-Dark";
      package = pkgs.catppuccin-gtk.override {
        accents = [ "blue" ];
        size = "standard";
        variant = "mocha";
      };
    };
    iconTheme = {
      #name = "Catppuccin-Mocha-Blue";
      name = "cat-mocha-blue";
      package = pkgs.catppuccin-papirus-folders.override {
        flavor = "mocha";
        accent = "blue";
      };
    };
    cursorTheme = {
      name = "Catppuccin-Mocha-Lavender-Cursors";
      package = pkgs.catppuccin-cursors.mochaLavender;
    };
    gtk3 = {
      extraConfig.gtk-application-prefer-dark-theme = true;
    };
  };
  dconf.settings = {
    "org/gtk/settings/file-chooser" = {
      sort-directories-first = true;
    };

    # GTK4 Setup
    "org/gnome/desktop/interface" = {
      gtk-theme = "Catppuccin-Mocha-Standard-Blue-Dark";
      color-scheme = "prefer-dark";
    };
  };

  xdg.configFile."Kvantum/kvantum.kvconfig".source = (pkgs.formats.ini { }).generate "kvantum.kvconfig" {
    General.theme = "Catppuccin-Mocha-Blue";
  };
}

And I have this in my configuration.nix:

  environment.systemPackages = with pkgs; [
    libsForQt5.qt5ct
  ];
  qt = {
    enable = true;
    platformTheme = "qt5ct";
    style= "kvantum";
  };

I think is some small little knob in the corner to turn…

I can get the icons to show in pcmanfm-qt if I set Edit → Preferences → Display → Icon Theme to Papirus-Dark. But that does not propagate to pavucontrol-qt for example.

1 Like

I figured out the icon problem. I think this is also the reason why pcmanfm-qt had no icons.

The issues is that QT apps don’t have their icon theme set by default, so you can configure each one individually like we did with pcmanfm-qt. However, a better solution is to do it for all of them using qt5ct, as the Arch wiki suggests.

Just open qt5ct > Icon Theme > Papirus-Dark then click Apply.

This isn’t exactly the Nix way of doing things, but it’s something that works for now. We could probably also do this by modifying $HOME/.config/qt5ct/qt5ct.conf using home-manager, but I don’t know how exactly.

I was wrong here. Using nixpkgs.config.qt was pretty much a workaround as ot turns out the applications that didn’t show the icons were using QT6, and setting QT_QPA_PLATFORMTHEME = "qt5ct" made them use that instead of qt6ct (I’ll fix this in my original answer).

This is the same issue that we faced with pcmanfm-qt, but with QT6 apps. Fixing that is pretty much just setting the interface theme as kvantum and icon theme as Papirus-Dark in qt6ct.


Note: if any pcmanfm-qt user is wondering why the Application Menu is empty when right clicking a file Open With > Other Applications, that’s because you need to add the following packages:

  environment.systemPackages = with pkgs; [
    lxqt.lxqt-menu-data
    shared-mime-info # optional, but nice to have
  ];
1 Like

AHA!

Got it working! I manually wrote the configuration files for qt5ct and qt6ct this way:

  xdg.configFile = lib.mkIf hasSeat {
    kvantum = {
      target = "Kvantum/kvantum.kvconfig";
      text = lib.generators.toINI { } {
        General.theme = "Catppuccin-Mocha-Blue";
      };
    };

    qt5ct = {
      target = "qt5ct/qt5ct.conf";
      text = lib.generators.toINI { } {
        Appearance = {
          icon_theme = "Papirus-Dark";
        };
      };
    };

    qt6ct = {
      target = "qt6ct/qt6ct.conf";
      text = lib.generators.toINI { } {
        Appearance = {
          icon_theme = "Papirus-Dark";
        };
      };
    };

My hasSeat is a boolean that only writes this file if I have a systemd-seat (graphical interface), I use the same configuration files for my headless server. I need this because I use impermanence (Erase your darlings: immutable infrastructure for mutable systems - Graham Christensen). Also, I don’t want to have to manually setup my icons in the other laptop.

My complete configuration file is now this: wm-theme with these extra packages system-wide:

    libsForQt5.qtstyleplugin-kvantum.
    libsForQt5.qt5ct # Magic for some Qt apps keep functionality.

But it seems those two could be moved to my user.

Thank you @eljamm @nex!

2 Likes

@eljamm do you still have your catpuccins working everywhere? I updated my system and lost the icons, cursors and themes. Have no Idea how to setup anymore.

Some things have changed since then, but I’m using catppuccin/nix and it’s working for me (you can check this out in my config). Can you share your current configuration?

Edit: More likely related to GTK settings suddenly not applying

Thanks for the hint on catppuccin.nix, that’s awesome!

I managed to get GTK working with Catppuccin theme, but not Qt. Here’s what I currently have:

{ machine, lib, pkgs, ... }:
let
  hasSeat = machine.seat != null;
  catppuccinFlavor = "macchiato";
  catppuccinAccent = "blue";
in
{
  home.packages = with pkgs; lib.mkIf hasSeat [
    papirus-folders
  ];

  # Mouse cursor
  catppuccin.pointerCursor = {
    enable = true;
    accent = catppuccinAccent;
    flavor = catppuccinFlavor;
  };

  # GTK Setup
  gtk = lib.mkIf hasSeat {
    enable = true;

    catppuccin = {
      #enable = true; # No need to set this anymore
      accent = catppuccinAccent;
      flavor = catppuccinFlavor;

      icon = {
        enable = true;
        accent = catppuccinAccent;
        flavor = catppuccinFlavor;
      };
    };

    gtk3.extraConfig.gtk-application-prefer-dark-theme = true;
  };

  # Qt setup - not working properly
  qt = lib.mkIf hasSeat {
    enable = true;

    platformTheme.name = "kvantum";
    style = {
      name = "kvantum";

      catppuccin = {
        enable = true;
        apply = true;
        accent = catppuccinAccent;
        flavor = catppuccinFlavor;
      };
    };
  };
}

I have no icons in Qt apps (e.g. pavucontrol-qt) and they are just plain white.

How to configure Qt?

This is how I have it set up right now:

Didn’t know a module for QT was added for catppuccin-nix :thinking:

It’s worth noting that my method isn’t fully reproducible as I’m using qtct to set kvantum as the theme. Although that can be done automatically as you’ve done before with the icon theme:

It worked back then, but the icons are not showing up anymore :frowning:

Do theme files exist under $XDG_CONFIG_HOME/Kvantum?

Do you see anything odd in the generated config files?

I see the files in there, with a SVG and a kvconfig files. The svg seems a bit odd to me:

Seems to be missing many icons, like folders for example? In the case of pavucontrol, the symbols for audio, mic, enabled, etc are not in this SVG. Should they be there?

What do you see in there?

Ah, right. That’s for the theme and not the icons. That’s perfectly normal.

Can you manually change the icon theme in qt5ct and qt6ct? You can change it to something else and see if it works, then back to Papirus-Dark and see if that works as well.

Oh, that makes sense.

Found something: I get a warning when I open qt6ct:

Please remove the QT_STYLE_OVERRIDE environment variable (current value: kvantum).

The QT_QPA_PLATFORMTHEME environment variable is not set correctly (current value: kvantum, required values: qt6ct or qt5ct).

I don’t set any of those environment variables manually. Do you have them in your env?

Those are set by the catppuccin QT module (see here).

I only have the QT_STYLE_OVERRIDE message since my platform theme is qt5ct.

I think that those are just warnings, though, right? or does this mean you can’t change the icon theme if you’re not using qt5ct as a platform theme?

I got the theme working, but not the icons. I can’t change them in qt5ct, it appears locked there.

My current config for Qt is:

let
  catppuccinAccent = "Blue";
  catppuccinFlavor = "Macchiato";

  catppuccinKvantum =  pkgs.catppuccin-kvantum.override {
      accent = catppuccinAccent;
      variant = catppuccinFlavor;
  };

  qtctConf = {
    Appearance = {
      custom_palette = false;
      icon_theme = "Papirus-Dark";
      standard_dialogs = "default";
      style = "kvantum";
    };
  };
in
{

  qt = lib.mkIf hasSeat {
    enable = true;
    platformTheme.name = "qtct";
    style.name = "kvantum";
  };
  xdg.configFile."qt5ct/qt5ct.conf".text = lib.generators.toINI { } qtctConf;
  xdg.configFile."qt6ct/qt6ct.conf".text = lib.generators.toINI { } qtctConf;
  xdg.configFile = {
    "Kvantum/kvantum.kvconfig".text = ''
      [General]
      theme=Catppuccin-${catppuccinFlavor}-${catppuccinAccent}
    '';

    "Kvantum/Catppuccin-${catppuccinFlavor}-${catppuccinAccent}".source = "${catppuccinKvantum}/share/Kvantum/Catppuccin-${catppuccinFlavor}-${catppuccinAccent}";
  };
};

Do you spot anything obviously wrong?

I have a feeling that the qtct configuration is not being applied, but don’t know how to check that. kvantummanager shows the theme nicely, but qt5ct appears to be locked in the icons.

Hey, @heitorpb, apologies for replying late, but I didn’t get a notification.

What I would suggest doing is checking if $HOME/.config/qt5ct/qt5ct.conf exists and has the correct contents. Else, I’d remove the lines where you declaratively configure qt5ct and qt6ct and I’d try manually getting it to work first.

Perhaps qt5ct wants its config file to be writeable or something?

I deleted $HOME/.config/qt{5,6}ct/, removed the static configs from my Nix files and tried to manually set the theme and icons and got nowhere. This is what I see in qt6ct:
qt6ct-icons

It seems papirus-dark is not available for qtct? Curiously, when I open pcmanfm-qt and go to the settings, I can set the icons to papirus-dark and they appear.

Weird. Do none of those options work at all?