Refactor theme management
Signed-off-by: Nikolaos Karaolidis <nick@karaolidis.com>
This commit is contained in:
@@ -15,7 +15,7 @@
|
||||
theme = {
|
||||
template."${home}/.config/btop/themes/matugen.theme".source = ./theme.theme;
|
||||
|
||||
extraConfig = "${
|
||||
reloadExtraConfig = "${
|
||||
lib.meta.getExe (
|
||||
pkgs.writeShellApplication {
|
||||
name = "reload-btop";
|
||||
|
@@ -57,7 +57,7 @@ in
|
||||
"${home}/.config/gtk-4.0/theme.css".source = ./theme.css;
|
||||
};
|
||||
|
||||
theme.extraConfig = "${
|
||||
theme.initExtraConfig = "${
|
||||
lib.meta.getExe (
|
||||
pkgs.writeShellApplication {
|
||||
name = "theme-gtk";
|
||||
|
@@ -140,7 +140,7 @@
|
||||
theme = {
|
||||
template."${home}/.config/hypr/theme.conf".source = ./theme.conf;
|
||||
|
||||
extraConfig = "${
|
||||
reloadExtraConfig = "${
|
||||
lib.meta.getExe (
|
||||
pkgs.writeShellApplication {
|
||||
name = "reload-hyprland";
|
||||
|
@@ -33,7 +33,7 @@ in
|
||||
theme = {
|
||||
template."${home}/.config/kitty/theme.conf".source = ./theme.conf;
|
||||
|
||||
extraConfig = "${
|
||||
reloadExtraConfig = "${
|
||||
lib.meta.getExe (
|
||||
pkgs.writeShellApplication {
|
||||
name = "reload-kitty";
|
||||
|
@@ -63,6 +63,6 @@ in
|
||||
Install.WantedBy = [ "graphical-session.target" ];
|
||||
};
|
||||
|
||||
theme.extraConfig = lib.mkAfter "${themeSwww} &";
|
||||
theme.reloadExtraConfig = "${themeSwww} &";
|
||||
};
|
||||
}
|
||||
|
@@ -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;
|
||||
|
@@ -38,7 +38,8 @@ finish() {
|
||||
[[ -n "${WALLPAPER}" ]] && ln -sf "${WALLPAPER}" "${CONFIG}"/wallpaper
|
||||
[[ -n "${MODE}" ]] && echo "${MODE}" > "${CONFIG}"/mode
|
||||
|
||||
"${ACTIVATION}" > /dev/null
|
||||
"${INIT}" > /dev/null
|
||||
"${RELOAD}" > /dev/null
|
||||
}
|
||||
|
||||
if [[ $# -eq 0 ]]; then
|
||||
|
Reference in New Issue
Block a user