Refactor theme module
Signed-off-by: Nikolaos Karaolidis <nick@karaolidis.com>
This commit is contained in:
@@ -23,10 +23,7 @@ in
|
||||
target = "ags/config.js";
|
||||
};
|
||||
|
||||
programs.matugen.settings.templates.ags = {
|
||||
input_path = ./theme.sass;
|
||||
output_path = "${hmConfig.xdg.configHome}/ags/theme.sass";
|
||||
};
|
||||
theme.templates."${hmConfig.xdg.configHome}/ags/theme.sass".source = ./theme.sass;
|
||||
|
||||
systemd.user = {
|
||||
targets.tray.Unit = {
|
||||
|
@@ -12,23 +12,20 @@ let
|
||||
in
|
||||
{
|
||||
home-manager.users.${username} = {
|
||||
programs = {
|
||||
btop.settings.color_theme = "matugen";
|
||||
programs.btop.settings.color_theme = "matugen";
|
||||
|
||||
matugen.settings.templates.btop = {
|
||||
input_path = ./theme.theme;
|
||||
output_path = "${hmConfig.xdg.configHome}/btop/themes/matugen.theme";
|
||||
};
|
||||
theme = {
|
||||
templates."${hmConfig.xdg.configHome}/btop/themes/matugen.theme".source = ./theme.theme;
|
||||
|
||||
extraConfig = "${
|
||||
lib.meta.getExe (
|
||||
pkgs.writeShellApplication {
|
||||
name = "reload-btop";
|
||||
runtimeInputs = with pkgs; [ procps ];
|
||||
text = "exec pkill btop -SIGUSR2";
|
||||
}
|
||||
)
|
||||
} &";
|
||||
};
|
||||
|
||||
theme.extraConfig = "${
|
||||
lib.meta.getExe (
|
||||
pkgs.writeShellApplication {
|
||||
name = "reload-btop";
|
||||
runtimeInputs = with pkgs; [ procps ];
|
||||
text = "exec pkill btop -SIGUSR2";
|
||||
}
|
||||
)
|
||||
} &";
|
||||
};
|
||||
}
|
||||
|
@@ -51,15 +51,9 @@ in
|
||||
);
|
||||
};
|
||||
|
||||
programs.matugen.settings.templates = {
|
||||
gtk3 = {
|
||||
input_path = ./theme.css;
|
||||
output_path = "${hmConfig.xdg.configHome}/gtk-3.0/theme.css";
|
||||
};
|
||||
gtk4 = {
|
||||
input_path = ./theme.css;
|
||||
output_path = "${hmConfig.xdg.configHome}/gtk-4.0/theme.css";
|
||||
};
|
||||
theme.templates = {
|
||||
"${hmConfig.xdg.configHome}/gtk-3.0/theme.css".source = ./theme.css;
|
||||
"${hmConfig.xdg.configHome}/gtk-4.0/theme.css".source = ./theme.css;
|
||||
};
|
||||
|
||||
theme.extraConfig = "${
|
||||
|
@@ -131,29 +131,26 @@ in
|
||||
extraConfig = "source = ./theme.conf";
|
||||
};
|
||||
|
||||
programs = {
|
||||
zsh.loginExtra = lib.mkAfter ''
|
||||
if [ -z "$WAYLAND_DISPLAY" ] && [ -n "$XDG_VTNR" ] && [ "$XDG_VTNR" -eq 1 ]; then
|
||||
hyprland &> /tmp/hyprland.log
|
||||
fi
|
||||
'';
|
||||
programs.zsh.loginExtra = lib.mkAfter ''
|
||||
if [ -z "$WAYLAND_DISPLAY" ] && [ -n "$XDG_VTNR" ] && [ "$XDG_VTNR" -eq 1 ]; then
|
||||
hyprland &> /tmp/hyprland.log
|
||||
fi
|
||||
'';
|
||||
|
||||
matugen.settings.templates.hyprland = {
|
||||
input_path = ./theme.conf;
|
||||
output_path = "${hmConfig.xdg.configHome}/hypr/theme.conf";
|
||||
};
|
||||
theme = {
|
||||
templates."${hmConfig.xdg.configHome}/hypr/theme.conf".source = ./theme.conf;
|
||||
|
||||
extraConfig = "${
|
||||
lib.meta.getExe (
|
||||
pkgs.writeShellApplication {
|
||||
name = "reload-hyprland";
|
||||
runtimeInputs = with pkgs; [ hyprland ];
|
||||
text = "exec hyprctl reload";
|
||||
}
|
||||
)
|
||||
} &";
|
||||
};
|
||||
|
||||
theme.extraConfig = "${
|
||||
lib.meta.getExe (
|
||||
pkgs.writeShellApplication {
|
||||
name = "reload-hyprland";
|
||||
runtimeInputs = with pkgs; [ hyprland ];
|
||||
text = "exec hyprctl reload";
|
||||
}
|
||||
)
|
||||
} &";
|
||||
|
||||
home.sessionVariables.NIXOS_OZONE_WL = "1";
|
||||
};
|
||||
}
|
||||
|
@@ -13,37 +13,34 @@ let
|
||||
in
|
||||
{
|
||||
home-manager.users.${username} = {
|
||||
programs = {
|
||||
kitty = {
|
||||
enable = true;
|
||||
programs.kitty = {
|
||||
enable = true;
|
||||
|
||||
font = {
|
||||
name = builtins.head hmConfig.theme.font.monospace.names;
|
||||
package = builtins.head hmConfig.theme.font.monospace.packages;
|
||||
inherit (hmConfig.theme.font) size;
|
||||
};
|
||||
|
||||
extraConfig = ''
|
||||
confirm_os_window_close 0
|
||||
include theme.conf
|
||||
'';
|
||||
font = {
|
||||
name = builtins.head hmConfig.theme.font.monospace.names;
|
||||
package = builtins.head hmConfig.theme.font.monospace.packages;
|
||||
inherit (hmConfig.theme.font) size;
|
||||
};
|
||||
|
||||
matugen.settings.templates.kitty = {
|
||||
input_path = ./theme.conf;
|
||||
output_path = "${hmConfig.xdg.configHome}/kitty/theme.conf";
|
||||
};
|
||||
extraConfig = ''
|
||||
confirm_os_window_close 0
|
||||
include theme.conf
|
||||
'';
|
||||
};
|
||||
|
||||
theme.extraConfig = "${
|
||||
lib.meta.getExe (
|
||||
pkgs.writeShellApplication {
|
||||
name = "reload-kitty";
|
||||
runtimeInputs = with pkgs; [ procps ];
|
||||
text = "exec pkill kitty -SIGUSR1";
|
||||
}
|
||||
)
|
||||
} &";
|
||||
theme = {
|
||||
templates."${hmConfig.xdg.configHome}/kitty/theme.conf".source = ./theme.conf;
|
||||
|
||||
extraConfig = "${
|
||||
lib.meta.getExe (
|
||||
pkgs.writeShellApplication {
|
||||
name = "reload-kitty";
|
||||
runtimeInputs = with pkgs; [ procps ];
|
||||
text = "exec pkill kitty -SIGUSR1";
|
||||
}
|
||||
)
|
||||
} &";
|
||||
};
|
||||
|
||||
home.persistence."/cache${userConfig.home}".directories = [
|
||||
"${hmConfig.xdg.relativeCacheHome}/kitty"
|
||||
|
@@ -1,100 +0,0 @@
|
||||
{
|
||||
username ? throw "username argument is required",
|
||||
}:
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
let
|
||||
hmConfig = config.home-manager.users.${username};
|
||||
in
|
||||
{
|
||||
home-manager.users.${username} = {
|
||||
imports = [ ./options.nix ];
|
||||
|
||||
programs.matugen = {
|
||||
enable = true;
|
||||
settings = {
|
||||
config = {
|
||||
custom_colors =
|
||||
let
|
||||
mkColor = category: color: {
|
||||
color = hmConfig.theme.color.${category}.${color};
|
||||
blend = hmConfig.theme.color.${category}.blend;
|
||||
};
|
||||
in
|
||||
{
|
||||
danger = mkColor "semantic" "danger";
|
||||
warning = mkColor "semantic" "warning";
|
||||
success = mkColor "semantic" "success";
|
||||
info = mkColor "semantic" "info";
|
||||
|
||||
red = mkColor "basic" "red";
|
||||
orange = mkColor "basic" "orange";
|
||||
yellow = mkColor "basic" "yellow";
|
||||
green = mkColor "basic" "green";
|
||||
cyan = mkColor "basic" "cyan";
|
||||
blue = mkColor "basic" "blue";
|
||||
magenta = mkColor "basic" "magenta";
|
||||
pink = mkColor "basic" "magenta";
|
||||
|
||||
keywords = mkColor "syntax" "keywords";
|
||||
functions = mkColor "syntax" "functions";
|
||||
properties = mkColor "syntax" "properties";
|
||||
constants = mkColor "syntax" "constants";
|
||||
strings = mkColor "syntax" "strings";
|
||||
numbers = mkColor "syntax" "numbers";
|
||||
structures = mkColor "syntax" "structures";
|
||||
types = mkColor "syntax" "types";
|
||||
};
|
||||
|
||||
custom_keywords =
|
||||
let
|
||||
zeroPad = hex: if builtins.stringLength hex == 1 then "0${hex}" else hex;
|
||||
percentageToHex = percentage: zeroPad (lib.trivial.toHexString (builtins.floor (percentage * 255)));
|
||||
in
|
||||
{
|
||||
flavour = hmConfig.theme.flavour;
|
||||
contrast = builtins.toString hmConfig.theme.contrast;
|
||||
radius = builtins.toString hmConfig.theme.radius;
|
||||
padding = builtins.toString hmConfig.theme.padding;
|
||||
padding_double = builtins.toString (hmConfig.theme.padding * 2);
|
||||
blur = builtins.toString hmConfig.theme.blur;
|
||||
opacity = builtins.toString hmConfig.theme.opacity;
|
||||
opacity_hex = builtins.toString (percentageToHex hmConfig.theme.opacity);
|
||||
opacity_shadow = builtins.toString (hmConfig.theme.opacity * 0.75);
|
||||
opacity_shadow_hex = builtins.toString (percentageToHex (hmConfig.theme.opacity * 0.75));
|
||||
font_size = builtins.toString hmConfig.theme.font.size;
|
||||
font_sans_serif = builtins.head hmConfig.theme.font.sansSerif.names;
|
||||
font_sans_serif_all = builtins.concatStringsSep ", " hmConfig.theme.font.sansSerif.names;
|
||||
font_serif = builtins.head hmConfig.theme.font.serif.names;
|
||||
font_serif_all = builtins.concatStringsSep ", " hmConfig.theme.font.serif.names;
|
||||
font_monospace = builtins.head hmConfig.theme.font.monospace.names;
|
||||
font_monospace_all = builtins.concatStringsSep ", " hmConfig.theme.font.monospace.names;
|
||||
font_emoji = builtins.head hmConfig.theme.font.emoji.names;
|
||||
font_emoji_all = builtins.concatStringsSep ", " hmConfig.theme.font.emoji.names;
|
||||
};
|
||||
};
|
||||
|
||||
templates = { };
|
||||
};
|
||||
};
|
||||
|
||||
theme.extraConfig = lib.mkBefore (
|
||||
lib.meta.getExe (
|
||||
pkgs.writeShellApplication {
|
||||
name = "theme-matugen";
|
||||
runtimeInputs = with pkgs; [ matugen ];
|
||||
text = ''
|
||||
exec matugen image "${hmConfig.theme.configDir}/wallpaper" \
|
||||
--type scheme-${hmConfig.theme.flavour} \
|
||||
--mode "$(cat "${hmConfig.theme.configDir}/mode")" \
|
||||
--contrast ${builtins.toString hmConfig.theme.contrast}
|
||||
'';
|
||||
}
|
||||
)
|
||||
);
|
||||
};
|
||||
}
|
@@ -1,30 +0,0 @@
|
||||
{
|
||||
config,
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
let
|
||||
cfg = config.programs.matugen;
|
||||
in
|
||||
{
|
||||
# https://github.com/Theaninova/matugen/blob/add-home-manager-module/hm-module.nix
|
||||
options.programs.matugen =
|
||||
with lib;
|
||||
with types;
|
||||
{
|
||||
enable = mkEnableOption "matugen";
|
||||
package = mkPackageOption pkgs "matugen" { };
|
||||
settings = mkOption {
|
||||
type = attrsOf anything;
|
||||
description = "Settings to write to config.toml.";
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
home.packages = [ cfg.package ];
|
||||
xdg.configFile."matugen/config.toml".source = lib.mkIf (cfg.settings != null) (
|
||||
(pkgs.formats.toml { }).generate "matugen" cfg.settings
|
||||
);
|
||||
};
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@@ -26,17 +26,11 @@ in
|
||||
QT_QPA_PLATFORMTHEME = "qt5ct";
|
||||
};
|
||||
|
||||
programs.matugen.settings.templates = {
|
||||
theme.templates = {
|
||||
# https://github.com/GabePoel/KvLibadwaita/blob/main/src/KvLibadwaita/KvLibadwaita.kvconfig
|
||||
kvantumConfig = {
|
||||
input_path = ./KvAdwQt/KvAdwQt.kvconfig;
|
||||
output_path = "${hmConfig.xdg.configHome}/Kvantum/KvAdwQt/KvAdwQt.kvconfig";
|
||||
};
|
||||
"${hmConfig.xdg.configHome}/Kvantum/KvAdwQt/KvAdwQt.kvconfig".source = ./KvAdwQt/KvAdwQt.kvconfig;
|
||||
# https://github.com/GabePoel/KvLibadwaita/blob/main/src/KvLibadwaita/KvLibadwaita.svg
|
||||
kvantumSvg = {
|
||||
input_path = ./KvAdwQt/KvAdwQt.svg;
|
||||
output_path = "${hmConfig.xdg.configHome}/Kvantum/KvAdwQt/KvAdwQt.svg";
|
||||
};
|
||||
"${hmConfig.xdg.configHome}/Kvantum/KvAdwQt/KvAdwQt.svg".source = ./KvAdwQt/KvAdwQt.svg;
|
||||
};
|
||||
|
||||
xdg.configFile =
|
||||
|
@@ -24,13 +24,8 @@ in
|
||||
"Ctrl_Alt, t, exec, ${themeBin} toggle"
|
||||
];
|
||||
|
||||
home = {
|
||||
activation.themeInit = inputs.home-manager.lib.hm.dag.entryAfter [
|
||||
"writeBoundary"
|
||||
] "run ${themeBin}";
|
||||
persistence."/persist${userConfig.home}".directories = [
|
||||
"${hmConfig.xdg.relativeConfigHome}/theme"
|
||||
];
|
||||
};
|
||||
home.persistence."/persist${userConfig.home}".directories = [
|
||||
"${hmConfig.xdg.relativeConfigHome}/theme"
|
||||
];
|
||||
};
|
||||
}
|
||||
|
@@ -1,12 +1,33 @@
|
||||
{
|
||||
config,
|
||||
inputs,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
let
|
||||
cfg = config.theme;
|
||||
init = pkgs.writeShellApplication {
|
||||
|
||||
activation = pkgs.writeShellApplication {
|
||||
name = "theme-init";
|
||||
runtimeInputs = with pkgs; [ matugen ];
|
||||
bashOptions = [
|
||||
"nounset"
|
||||
"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}
|
||||
'';
|
||||
};
|
||||
|
||||
theme = pkgs.writeShellApplication {
|
||||
name = "theme";
|
||||
runtimeInputs = with pkgs; [ coreutils ];
|
||||
bashOptions = [
|
||||
@@ -17,7 +38,7 @@ let
|
||||
CONFIG = cfg.configDir;
|
||||
DEFAULT_WALLPAPER = cfg.wallpaper;
|
||||
DEFAULT_MODE = cfg.mode;
|
||||
SWITCH = lib.meta.getExe (pkgs.writeShellScriptBin "themeExtraConfig" cfg.extraConfig);
|
||||
ACTIVATION = lib.meta.getExe activation;
|
||||
};
|
||||
text = builtins.readFile ./theme.sh;
|
||||
};
|
||||
@@ -43,7 +64,7 @@ in
|
||||
|
||||
pkg = mkOption {
|
||||
type = package;
|
||||
default = init;
|
||||
default = theme;
|
||||
readOnly = true;
|
||||
description = "The package containing the `theme` script";
|
||||
};
|
||||
@@ -51,7 +72,40 @@ in
|
||||
extraConfig = mkOption {
|
||||
type = lines;
|
||||
default = "";
|
||||
description = "Extra configuration lines to add to the theme script.";
|
||||
description = "Extra configuration lines to add to the theme reload script.";
|
||||
};
|
||||
|
||||
templates = mkOption {
|
||||
type = attrsOf (
|
||||
submodule (
|
||||
{ name, config, ... }:
|
||||
{
|
||||
options = {
|
||||
source = mkOption {
|
||||
type = nullOr path;
|
||||
description = "Path of the source file or directory.";
|
||||
default = null;
|
||||
};
|
||||
|
||||
text = mkOption {
|
||||
type = nullOr str;
|
||||
description = "Text of the file.";
|
||||
default = null;
|
||||
};
|
||||
|
||||
target = mkOption {
|
||||
type = str;
|
||||
defaultText = literalExpression "name";
|
||||
description = "Path to target relative to the user's {env}`HOME`.";
|
||||
};
|
||||
};
|
||||
|
||||
config.target = mkDefault name;
|
||||
}
|
||||
)
|
||||
);
|
||||
default = { };
|
||||
description = "Templates to fill with theme colors.";
|
||||
};
|
||||
|
||||
flavour = mkOption {
|
||||
@@ -112,7 +166,7 @@ in
|
||||
semantic = {
|
||||
blend = mkOption {
|
||||
type = bool;
|
||||
default = false;
|
||||
default = true;
|
||||
description = "Blend the colors.";
|
||||
};
|
||||
|
||||
@@ -364,8 +418,16 @@ in
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
home = {
|
||||
activation.themeInit = inputs.home-manager.lib.hm.dag.entryAfter [
|
||||
"writeBoundary"
|
||||
] "run ${lib.meta.getExe activation}";
|
||||
|
||||
packages =
|
||||
[ cfg.pkg ]
|
||||
with pkgs;
|
||||
[
|
||||
matugen
|
||||
theme
|
||||
]
|
||||
++ cfg.font.sansSerif.packages
|
||||
++ cfg.font.serif.packages
|
||||
++ cfg.font.monospace.packages
|
||||
@@ -389,5 +451,75 @@ in
|
||||
emoji = cfg.font.emoji.names;
|
||||
};
|
||||
};
|
||||
|
||||
xdg.configFile."matugen/config.toml".source = (
|
||||
(pkgs.formats.toml { }).generate "matugen" {
|
||||
config = {
|
||||
custom_colors =
|
||||
let
|
||||
mkColor = category: color: {
|
||||
color = cfg.color.${category}.${color};
|
||||
blend = cfg.color.${category}.blend;
|
||||
};
|
||||
in
|
||||
{
|
||||
danger = mkColor "semantic" "danger";
|
||||
warning = mkColor "semantic" "warning";
|
||||
success = mkColor "semantic" "success";
|
||||
info = mkColor "semantic" "info";
|
||||
|
||||
red = mkColor "basic" "red";
|
||||
orange = mkColor "basic" "orange";
|
||||
yellow = mkColor "basic" "yellow";
|
||||
green = mkColor "basic" "green";
|
||||
cyan = mkColor "basic" "cyan";
|
||||
blue = mkColor "basic" "blue";
|
||||
magenta = mkColor "basic" "magenta";
|
||||
pink = mkColor "basic" "pink";
|
||||
|
||||
keywords = mkColor "syntax" "keywords";
|
||||
functions = mkColor "syntax" "functions";
|
||||
properties = mkColor "syntax" "properties";
|
||||
constants = mkColor "syntax" "constants";
|
||||
strings = mkColor "syntax" "strings";
|
||||
numbers = mkColor "syntax" "numbers";
|
||||
structures = mkColor "syntax" "structures";
|
||||
types = mkColor "syntax" "types";
|
||||
};
|
||||
|
||||
custom_keywords =
|
||||
let
|
||||
zeroPad = hex: if builtins.stringLength hex == 1 then "0${hex}" else hex;
|
||||
percentageToHex = percentage: zeroPad (lib.trivial.toHexString (builtins.floor (percentage * 255)));
|
||||
in
|
||||
{
|
||||
flavour = cfg.flavour;
|
||||
contrast = builtins.toString cfg.contrast;
|
||||
radius = builtins.toString cfg.radius;
|
||||
padding = builtins.toString cfg.padding;
|
||||
padding_double = builtins.toString (cfg.padding * 2);
|
||||
blur = builtins.toString cfg.blur;
|
||||
opacity = builtins.toString cfg.opacity;
|
||||
opacity_hex = builtins.toString (percentageToHex cfg.opacity);
|
||||
opacity_shadow = builtins.toString (cfg.opacity * 0.75);
|
||||
opacity_shadow_hex = builtins.toString (percentageToHex (cfg.opacity * 0.75));
|
||||
font_size = builtins.toString cfg.font.size;
|
||||
font_sans_serif = builtins.head cfg.font.sansSerif.names;
|
||||
font_sans_serif_all = builtins.concatStringsSep ", " cfg.font.sansSerif.names;
|
||||
font_serif = builtins.head cfg.font.serif.names;
|
||||
font_serif_all = builtins.concatStringsSep ", " cfg.font.serif.names;
|
||||
font_monospace = builtins.head cfg.font.monospace.names;
|
||||
font_monospace_all = builtins.concatStringsSep ", " cfg.font.monospace.names;
|
||||
font_emoji = builtins.head cfg.font.emoji.names;
|
||||
font_emoji_all = builtins.concatStringsSep ", " cfg.font.emoji.names;
|
||||
};
|
||||
};
|
||||
|
||||
templates = builtins.mapAttrs (name: template: {
|
||||
input_path = template.source or (pkgs.writeText name template.text);
|
||||
output_path = template.target;
|
||||
}) cfg.templates;
|
||||
}
|
||||
);
|
||||
};
|
||||
}
|
||||
|
@@ -1,6 +1,9 @@
|
||||
[ ! -L "$CONFIG"/wallpaper ] && ln -sf "$DEFAULT_WALLPAPER" "$CONFIG"/wallpaper
|
||||
[ ! -f "$CONFIG"/mode ] && echo "$DEFAULT_MODE" > "$CONFIG"/mode
|
||||
|
||||
WALLPAPER=""
|
||||
MODE=""
|
||||
|
||||
set_wallpaper() {
|
||||
if [ -f "$1" ]; then
|
||||
WALLPAPER="$1"
|
||||
@@ -35,14 +38,9 @@ finish() {
|
||||
[ -n "$WALLPAPER" ] && ln -sf "$WALLPAPER" "$CONFIG"/wallpaper
|
||||
[ -n "$MODE" ] && echo "$MODE" > "$CONFIG"/mode
|
||||
|
||||
{
|
||||
"$SWITCH"
|
||||
} > /dev/null
|
||||
"$ACTIVATION" > /dev/null
|
||||
}
|
||||
|
||||
WALLPAPER=""
|
||||
MODE=""
|
||||
|
||||
if [ $# -eq 0 ]; then
|
||||
finish
|
||||
else
|
||||
|
Reference in New Issue
Block a user