Refactor theme management
Signed-off-by: Nikolaos Karaolidis <nick@karaolidis.com>
This commit is contained in:
@@ -8,25 +8,24 @@
|
||||
let
|
||||
cfg = config.theme;
|
||||
|
||||
activation = pkgs.writeShellApplication {
|
||||
init = pkgs.writeShellApplication {
|
||||
name = "theme-init";
|
||||
runtimeInputs = with pkgs; [ matugen ];
|
||||
bashOptions = [
|
||||
"errexit"
|
||||
"pipefail"
|
||||
];
|
||||
text = ''
|
||||
matugen image "${cfg.configDir}/wallpaper" \
|
||||
--type scheme-${cfg.flavour} \
|
||||
--mode "$(cat "${cfg.configDir}/mode")" \
|
||||
--contrast ${builtins.toString cfg.contrast}
|
||||
|
||||
[ -z "$DISPLAY" ] && [ -z "$WAYLAND_DISPLAY" ] && exit 0
|
||||
|
||||
${cfg.extraConfig}
|
||||
${cfg.initExtraConfig}
|
||||
'';
|
||||
};
|
||||
|
||||
reload = pkgs.writeShellApplication {
|
||||
name = "theme-reload";
|
||||
text = cfg.reloadExtraConfig;
|
||||
};
|
||||
|
||||
theme = pkgs.writeShellApplication {
|
||||
name = "theme";
|
||||
runtimeInputs = with pkgs; [ coreutils ];
|
||||
@@ -34,7 +33,8 @@ let
|
||||
CONFIG = cfg.configDir;
|
||||
DEFAULT_WALLPAPER = cfg.wallpaper;
|
||||
DEFAULT_MODE = cfg.mode;
|
||||
ACTIVATION = lib.meta.getExe activation;
|
||||
INIT = lib.meta.getExe init;
|
||||
RELOAD = lib.meta.getExe reload;
|
||||
};
|
||||
text = builtins.readFile ./theme.sh;
|
||||
};
|
||||
@@ -65,7 +65,13 @@ in
|
||||
description = "The package containing the `theme` script";
|
||||
};
|
||||
|
||||
extraConfig = mkOption {
|
||||
initExtraConfig = mkOption {
|
||||
type = lines;
|
||||
default = "";
|
||||
description = "Extra configuration lines to add to the theme initialization script.";
|
||||
};
|
||||
|
||||
reloadExtraConfig = mkOption {
|
||||
type = lines;
|
||||
default = "";
|
||||
description = "Extra configuration lines to add to the theme reload script.";
|
||||
@@ -416,7 +422,8 @@ in
|
||||
home = {
|
||||
activation.themeInit = inputs.home-manager.lib.hm.dag.entryAfter [
|
||||
"writeBoundary"
|
||||
] "run ${lib.meta.getExe activation}";
|
||||
"dconfSettings"
|
||||
] "run ${lib.meta.getExe init}";
|
||||
|
||||
packages =
|
||||
with pkgs;
|
||||
|
Reference in New Issue
Block a user