Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(qt): allow theming for apps started by systemd #4349

Merged
merged 2 commits into from
Aug 17, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 18 additions & 11 deletions modules/misc/qt.nix
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,20 @@ in {
};
};

config = mkIf (cfg.enable && cfg.platformTheme != null) {
config = let

# Necessary because home.sessionVariables doesn't support mkIf
envVars = filterAttrs (n: v: v != null) {
QT_QPA_PLATFORMTHEME = if cfg.platformTheme == "gtk" then
"gtk2"
else if cfg.platformTheme == "qtct" then
"qt5ct"
else
cfg.platformTheme;
QT_STYLE_OVERRIDE = cfg.style.name;
};

in mkIf (cfg.enable && cfg.platformTheme != null) {
assertions = [{
assertion = cfg.platformTheme == "gnome" -> cfg.style.name != null
&& cfg.style.package != null;
Expand All @@ -141,16 +154,10 @@ in {
qt.style.package = mkIf (cfg.style.name != null)
(mkDefault (stylePackages.${toLower cfg.style.name} or null));

# Necessary because home.sessionVariables doesn't support mkIf
home.sessionVariables = filterAttrs (n: v: v != null) {
QT_QPA_PLATFORMTHEME = if cfg.platformTheme == "gtk" then
"gtk2"
else if cfg.platformTheme == "qtct" then
"qt5ct"
else
cfg.platformTheme;
QT_STYLE_OVERRIDE = cfg.style.name;
};
home.sessionVariables = envVars;

# Apply theming also to apps started by systemd.
systemd.user.sessionVariables = envVars;

home.packages = (if cfg.platformTheme == "gnome" then
[ pkgs.qgnomeplatform ]
Expand Down