Add soundtheme, windowdecorations and splashscreen theming support (#219)

This commit is contained in:
magnouvean 2024-06-20 12:54:02 +02:00 committed by GitHub
parent 7f56912a4f
commit d6fc3d0e71
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -54,6 +54,8 @@ let
(cfg.workspace.cursor != null && cfg.workspace.cursor.theme != null) ||
cfg.workspace.lookAndFeel != null ||
cfg.workspace.iconTheme != null);
splashScreenEngineDetect = theme: (if (theme == "None") then "none" else "KSplashQML");
in
{
imports = [
@ -124,7 +126,7 @@ in
};
wallpaper = lib.mkOption {
type = lib.types.nullOr lib.types.path;
type = with lib.types; nullOr path;
default = null;
example = "${pkgs.kdePackages.plasma-workspace-wallpapers}/share/wallpapers/Kay/contents/images/1080x1920.png";
description = ''
@ -149,6 +151,63 @@ in
Allows you to set wallpaper using the picture of the day plugin. Needs the provider.
'';
};
soundTheme = lib.mkOption {
type = with lib.types; nullOr str;
default = null;
example = "freedesktop";
description = ''
The sound-theme to use with plasma.
'';
};
splashScreen = {
engine = lib.mkOption {
type = with lib.types; nullOr str;
default = null;
example = "none";
description = ''
The engine for the splash-screen theme. If not specified it will try
to set an appropriate engine for you, but if this doesn't work you
might want to manually specify this.
'';
};
theme = lib.mkOption {
type = with lib.types; nullOr str;
default = null;
example = "None";
description = ''
The splash-screen theme shown at login. To see available values see the
Theme key in ~/.config/ksplashrc after applying the splash-screen via
the settings app. Can also be set to "None" to disable the splash-screen
altogether.
'';
};
};
windowDecorations = {
library = lib.mkOption {
type = with lib.types; nullOr str;
default = null;
example = "org.kde.kwin.aurorae";
description = ''
The library for the window decorations theme. To see available values
see the library key in the org.kde.kdecoration2 section of
~/.config/kdeglobals after applying the window-decoration via the
settings app.
'';
};
theme = lib.mkOption {
type = with lib.types; nullOr str;
default = null;
example = "__aurorae__svg__CatppuccinMocha-Modern";
description = ''
The window decorations theme. To see available values see the theme key
in the org.kde.kdecoration2 section of ~/.config/kdeglobals after
applying the window-decoration via the settings app.
'';
};
};
};
config = (lib.mkIf cfg.enable {
@ -161,19 +220,54 @@ in
lib.count (x: x != null) wallpapers <= 1;
message = "Can set only one of wallpaper, wallpaperSlideShow and wallpaperPictureOfTheDay.";
}
{
assertion = (cfg.workspace.splashScreen.engine == null || cfg.workspace.splashScreen.theme != null);
message = ''
Cannot set plasma.workspace.splashScreen.engine without a
corresponding theme.
'';
}
{
assertion = !(lib.xor (cfg.workspace.windowDecorations.theme == null) (cfg.workspace.windowDecorations.library == null));
message = ''
Must set both plasma.workspace.windowDecorations.library and
plasma.workspace.windowDecorations.theme or none.
'';
}
];
warnings = (if
((cfg.workspace.lookAndFeel != null) &&
(cfg.workspace.splashScreen.theme != null ||
cfg.workspace.windowDecorations.theme != null)) then
[
''Setting lookAndFeel together with splashScreen or windowDecorations in
plasma-manager is not recommended since lookAndFeel themes often
override these settings. Consider setting each part in the lookAndFeel
theme manually.''
] else [ ]);
programs.plasma.configFile = (lib.mkMerge [
{
kdeglobals = (lib.mkIf (cfg.workspace.clickItemTo != null) {
KDE.SingleClick = (cfg.workspace.clickItemTo == "open");
});
kdeglobals = {
KDE.SingleClick = (lib.mkIf (cfg.workspace.clickItemTo != null) (cfg.workspace.clickItemTo == "open"));
Sounds.Theme = (lib.mkIf (cfg.workspace.soundTheme != null) cfg.workspace.soundTheme);
};
plasmarc = (lib.mkIf (cfg.workspace.tooltipDelay != null) {
PlasmaToolTips.Delay = cfg.workspace.tooltipDelay;
});
kcminputrc = (lib.mkIf (cfg.workspace.cursor != null && cfg.workspace.cursor.size != null) {
Mouse.cursorSize = cfg.workspace.cursor.size;
});
ksplashrc.KSplash = (lib.mkIf (cfg.workspace.splashScreen.theme != null) {
Engine = (if (cfg.workspace.splashScreen.engine == null) then
(splashScreenEngineDetect cfg.workspace.splashScreen.theme)
else cfg.workspace.splashScreen.engine);
Theme = cfg.workspace.splashScreen.theme;
});
kwinrc = (lib.mkIf (cfg.workspace.windowDecorations.theme != null) {
"org.kde.kdecoration2".library = cfg.workspace.windowDecorations.library;
"org.kde.kdecoration2".theme = cfg.workspace.windowDecorations.theme;
});
}
# We add persistence to some keys in order to not reset the themes on
# each generation when we use overrideConfig.
@ -208,9 +302,9 @@ in
${if cfg.workspace.lookAndFeel != null then "plasma-apply-lookandfeel -a ${cfg.workspace.lookAndFeel}" else ""}
${if cfg.workspace.theme != null then "plasma-apply-desktoptheme ${cfg.workspace.theme}" else ""}
${if (cfg.workspace.cursor != null && cfg.workspace.cursor.theme != null) then
"plasma-apply-cursortheme ${cfg.workspace.cursor.theme}" +
(if cfg.workspace.cursor.size != null then " --size ${builtins.toString cfg.workspace.cursor.size}" else "")
else ""}
"plasma-apply-cursortheme ${cfg.workspace.cursor.theme}" +
(if cfg.workspace.cursor.size != null then " --size ${builtins.toString cfg.workspace.cursor.size}" else "")
else ""}
${if cfg.workspace.colorScheme != null then "plasma-apply-colorscheme ${cfg.workspace.colorScheme}" else ""}
${if cfg.workspace.iconTheme != null then "${pkgs.kdePackages.plasma-workspace}/libexec/plasma-changeicons ${cfg.workspace.iconTheme}" else ""}
'';