Fix qt theme

This commit is contained in:
ItsDrike 2024-06-23 18:11:45 +02:00
parent d796eea045
commit 6bedfed95c
Signed by: ItsDrike
GPG key ID: FA2745890B7048C0
3 changed files with 43 additions and 6 deletions

View file

@ -2,7 +2,6 @@
osConfig, osConfig,
config, config,
pkgs, pkgs,
lib,
... ...
}: let }: let
cfg = osConfig.myOptions.home-manager.theme.gtk; cfg = osConfig.myOptions.home-manager.theme.gtk;
@ -77,4 +76,10 @@ in {
gtk-application-prefer-dark-theme = true; gtk-application-prefer-dark-theme = true;
}; };
}; };
dconf.settings = {
"org/gnome/desktop/interface".gtk-theme = cfg.theme.name;
# For Gnome shell
"org/gnome/shell/extensions/user-theme".name = cfg.theme.name;
};
} }

View file

@ -10,9 +10,13 @@
in { in {
qt = { qt = {
enable = true; enable = true;
platformTheme.name = mkIf cfg.forceGtk "gtk"; # just an override for QT_QPA_PLATFORMTHEME, takes "gtk", "gnome", "qtct" or "kde" # just an override for QT_QPA_PLATFORMTHEME, takes "gtk", "gnome", "qtct" or "kde"
platformTheme.name =
if cfg.forceGtk
then "gtk"
else "qtct";
style = mkIf (!cfg.forceGtk) { style = mkIf (!cfg.forceGtk) {
name = cfg.theme.name; name = "Kvantum";
package = cfg.theme.package; package = cfg.theme.package;
}; };
}; };
@ -35,6 +39,16 @@ in {
libsForQt5.qtstyleplugins libsForQt5.qtstyleplugins
qt6Packages.qt6gtk2 qt6Packages.qt6gtk2
]) ])
(mkIf (!cfg.forceGtk) [
# If we're not forcing GTK themes, use Kvantum.
# Kvantum as a library and a program to theme qt applications.
qt6Packages.qtstyleplugin-kvantum
libsForQt5.qtstyleplugin-kvantum
# Also add the theme package to path just in case
cfg.theme.package
])
]; ];
sessionVariables = { sessionVariables = {
@ -53,5 +67,11 @@ in {
# tell calibre to use the dark theme, because the light one hurts my eyes # tell calibre to use the dark theme, because the light one hurts my eyes
CALIBRE_USE_DARK_PALETTE = "1"; CALIBRE_USE_DARK_PALETTE = "1";
}; };
xdg.configFile = mkIf (!cfg.forceGtk) {
"Kvantum/kvantum.kvconfig".source = (pkgs.formats.ini {}).generate "kvantum.kvconfig" {
General.theme = cfg.theme.name;
};
};
}; };
} }

View file

@ -62,19 +62,31 @@ in
forceGtk = mkOption { forceGtk = mkOption {
type = types.bool; type = types.bool;
default = false; default = false;
description = "Whether to force QT applications to try and use the GTK theme."; description = ''
Whether to force QT applications to try and use the GTK theme.
If false, qtct platform theme & Kvantum will be used instead.
'';
}; };
theme = { theme = {
name = mkOption { name = mkOption {
type = types.str; type = types.str;
default = "Catppuccin-Mocha-Dark"; default = "Catppuccin-Mocha-Dark";
description = "The name for the QT theme package"; description = ''
The name for the QT theme package.
This has no effect if forceGtk is set.
'';
}; };
package = mkOption { package = mkOption {
type = types.package; type = types.package;
description = "The theme package to be used for QT programs"; description = ''
The theme package to be used for QT programs.
This has no effect if forceGtk is set.
'';
default = pkgs.catppuccin-kde.override { default = pkgs.catppuccin-kde.override {
flavour = ["mocha"]; flavour = ["mocha"];
accents = ["blue"]; accents = ["blue"];