mirror of
https://github.com/nix-community/home-manager.git
synced 2025-11-08 19:46:05 +01:00
btop: add themes option (#6777)
This commit is contained in:
parent
bd33ce4000
commit
0daadc7784
3 changed files with 155 additions and 2 deletions
|
|
@ -41,6 +41,58 @@ in {
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
themes = lib.mkOption {
|
||||||
|
type = with lib.types; lazyAttrsOf (either path lines);
|
||||||
|
default = { };
|
||||||
|
example = ''
|
||||||
|
theme[main_bg]="#282a36"
|
||||||
|
theme[main_fg]="#f8f8f2"
|
||||||
|
theme[title]="#f8f8f2"
|
||||||
|
theme[hi_fg]="#6272a4"
|
||||||
|
theme[selected_bg]="#ff79c6"
|
||||||
|
theme[selected_fg]="#f8f8f2"
|
||||||
|
theme[inactive_fg]="#44475a"
|
||||||
|
theme[graph_text]="#f8f8f2"
|
||||||
|
theme[meter_bg]="#44475a"
|
||||||
|
theme[proc_misc]="#bd93f9"
|
||||||
|
theme[cpu_box]="#bd93f9"
|
||||||
|
theme[mem_box]="#50fa7b"
|
||||||
|
theme[net_box]="#ff5555"
|
||||||
|
theme[proc_box]="#8be9fd"
|
||||||
|
theme[div_line]="#44475a"
|
||||||
|
theme[temp_start]="#bd93f9"
|
||||||
|
theme[temp_mid]="#ff79c6"
|
||||||
|
theme[temp_end]="#ff33a8"
|
||||||
|
theme[cpu_start]="#bd93f9"
|
||||||
|
theme[cpu_mid]="#8be9fd"
|
||||||
|
theme[cpu_end]="#50fa7b"
|
||||||
|
theme[free_start]="#ffa6d9"
|
||||||
|
theme[free_mid]="#ff79c6"
|
||||||
|
theme[free_end]="#ff33a8"
|
||||||
|
theme[cached_start]="#b1f0fd"
|
||||||
|
theme[cached_mid]="#8be9fd"
|
||||||
|
theme[cached_end]="#26d7fd"
|
||||||
|
theme[available_start]="#ffd4a6"
|
||||||
|
theme[available_mid]="#ffb86c"
|
||||||
|
theme[available_end]="#ff9c33"
|
||||||
|
theme[used_start]="#96faaf"
|
||||||
|
theme[used_mid]="#50fa7b"
|
||||||
|
theme[used_end]="#0dfa49"
|
||||||
|
theme[download_start]="#bd93f9"
|
||||||
|
theme[download_mid]="#50fa7b"
|
||||||
|
theme[download_end]="#8be9fd"
|
||||||
|
theme[upload_start]="#8c42ab"
|
||||||
|
theme[upload_mid]="#ff79c6"
|
||||||
|
theme[upload_end]="#ff33a8"
|
||||||
|
theme[process_start]="#50fa7b"
|
||||||
|
theme[process_mid]="#59b690"
|
||||||
|
theme[process_end]="#6272a4"
|
||||||
|
'';
|
||||||
|
description = ''
|
||||||
|
Themes to be written to {file}`$XDG_CONFIG_HOME/btop/themes/''${name}.theme`
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
extraConfig = lib.mkOption {
|
extraConfig = lib.mkOption {
|
||||||
type = lib.types.lines;
|
type = lib.types.lines;
|
||||||
default = "";
|
default = "";
|
||||||
|
|
@ -53,7 +105,18 @@ in {
|
||||||
config = lib.mkIf cfg.enable {
|
config = lib.mkIf cfg.enable {
|
||||||
home.packages = lib.mkIf (cfg.package != null) [ cfg.package ];
|
home.packages = lib.mkIf (cfg.package != null) [ cfg.package ];
|
||||||
|
|
||||||
xdg.configFile."btop/btop.conf" =
|
xdg.configFile = let
|
||||||
lib.mkIf (cfg.settings != { }) { text = finalConfig; };
|
mkThemeConfig = name: theme: {
|
||||||
|
name = "btop/themes/${name}.theme";
|
||||||
|
value = {
|
||||||
|
source = (if builtins.isPath theme || lib.isStorePath theme then
|
||||||
|
theme
|
||||||
|
else
|
||||||
|
pkgs.writeText "btop-theme.theme" theme);
|
||||||
|
};
|
||||||
|
};
|
||||||
|
in {
|
||||||
|
"btop/btop.conf" = lib.mkIf (cfg.settings != { }) { text = finalConfig; };
|
||||||
|
} // lib.mapAttrs' mkThemeConfig cfg.themes;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,11 +24,59 @@
|
||||||
extraConfig = ''
|
extraConfig = ''
|
||||||
clock_format = "%H:%M"
|
clock_format = "%H:%M"
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
themes.example = ''
|
||||||
|
theme[main_bg]="#282a36"
|
||||||
|
theme[main_fg]="#f8f8f2"
|
||||||
|
theme[title]="#f8f8f2"
|
||||||
|
theme[hi_fg]="#6272a4"
|
||||||
|
theme[selected_bg]="#ff79c6"
|
||||||
|
theme[selected_fg]="#f8f8f2"
|
||||||
|
theme[inactive_fg]="#44475a"
|
||||||
|
theme[graph_text]="#f8f8f2"
|
||||||
|
theme[meter_bg]="#44475a"
|
||||||
|
theme[proc_misc]="#bd93f9"
|
||||||
|
theme[cpu_box]="#bd93f9"
|
||||||
|
theme[mem_box]="#50fa7b"
|
||||||
|
theme[net_box]="#ff5555"
|
||||||
|
theme[proc_box]="#8be9fd"
|
||||||
|
theme[div_line]="#44475a"
|
||||||
|
theme[temp_start]="#bd93f9"
|
||||||
|
theme[temp_mid]="#ff79c6"
|
||||||
|
theme[temp_end]="#ff33a8"
|
||||||
|
theme[cpu_start]="#bd93f9"
|
||||||
|
theme[cpu_mid]="#8be9fd"
|
||||||
|
theme[cpu_end]="#50fa7b"
|
||||||
|
theme[free_start]="#ffa6d9"
|
||||||
|
theme[free_mid]="#ff79c6"
|
||||||
|
theme[free_end]="#ff33a8"
|
||||||
|
theme[cached_start]="#b1f0fd"
|
||||||
|
theme[cached_mid]="#8be9fd"
|
||||||
|
theme[cached_end]="#26d7fd"
|
||||||
|
theme[available_start]="#ffd4a6"
|
||||||
|
theme[available_mid]="#ffb86c"
|
||||||
|
theme[available_end]="#ff9c33"
|
||||||
|
theme[used_start]="#96faaf"
|
||||||
|
theme[used_mid]="#50fa7b"
|
||||||
|
theme[used_end]="#0dfa49"
|
||||||
|
theme[download_start]="#bd93f9"
|
||||||
|
theme[download_mid]="#50fa7b"
|
||||||
|
theme[download_end]="#8be9fd"
|
||||||
|
theme[upload_start]="#8c42ab"
|
||||||
|
theme[upload_mid]="#ff79c6"
|
||||||
|
theme[upload_end]="#ff33a8"
|
||||||
|
theme[process_start]="#50fa7b"
|
||||||
|
theme[process_mid]="#59b690"
|
||||||
|
theme[process_end]="#6272a4"
|
||||||
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
nmt.script = ''
|
nmt.script = ''
|
||||||
assertFileContent \
|
assertFileContent \
|
||||||
home-files/.config/btop/btop.conf \
|
home-files/.config/btop/btop.conf \
|
||||||
${./example-settings-expected.conf}
|
${./example-settings-expected.conf}
|
||||||
|
assertFileContent \
|
||||||
|
home-files/.config/btop/themes/example.theme \
|
||||||
|
${./example-theme-expected.theme}
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
|
|
|
||||||
42
tests/modules/programs/btop/example-theme-expected.theme
Normal file
42
tests/modules/programs/btop/example-theme-expected.theme
Normal file
|
|
@ -0,0 +1,42 @@
|
||||||
|
theme[main_bg]="#282a36"
|
||||||
|
theme[main_fg]="#f8f8f2"
|
||||||
|
theme[title]="#f8f8f2"
|
||||||
|
theme[hi_fg]="#6272a4"
|
||||||
|
theme[selected_bg]="#ff79c6"
|
||||||
|
theme[selected_fg]="#f8f8f2"
|
||||||
|
theme[inactive_fg]="#44475a"
|
||||||
|
theme[graph_text]="#f8f8f2"
|
||||||
|
theme[meter_bg]="#44475a"
|
||||||
|
theme[proc_misc]="#bd93f9"
|
||||||
|
theme[cpu_box]="#bd93f9"
|
||||||
|
theme[mem_box]="#50fa7b"
|
||||||
|
theme[net_box]="#ff5555"
|
||||||
|
theme[proc_box]="#8be9fd"
|
||||||
|
theme[div_line]="#44475a"
|
||||||
|
theme[temp_start]="#bd93f9"
|
||||||
|
theme[temp_mid]="#ff79c6"
|
||||||
|
theme[temp_end]="#ff33a8"
|
||||||
|
theme[cpu_start]="#bd93f9"
|
||||||
|
theme[cpu_mid]="#8be9fd"
|
||||||
|
theme[cpu_end]="#50fa7b"
|
||||||
|
theme[free_start]="#ffa6d9"
|
||||||
|
theme[free_mid]="#ff79c6"
|
||||||
|
theme[free_end]="#ff33a8"
|
||||||
|
theme[cached_start]="#b1f0fd"
|
||||||
|
theme[cached_mid]="#8be9fd"
|
||||||
|
theme[cached_end]="#26d7fd"
|
||||||
|
theme[available_start]="#ffd4a6"
|
||||||
|
theme[available_mid]="#ffb86c"
|
||||||
|
theme[available_end]="#ff9c33"
|
||||||
|
theme[used_start]="#96faaf"
|
||||||
|
theme[used_mid]="#50fa7b"
|
||||||
|
theme[used_end]="#0dfa49"
|
||||||
|
theme[download_start]="#bd93f9"
|
||||||
|
theme[download_mid]="#50fa7b"
|
||||||
|
theme[download_end]="#8be9fd"
|
||||||
|
theme[upload_start]="#8c42ab"
|
||||||
|
theme[upload_mid]="#ff79c6"
|
||||||
|
theme[upload_end]="#ff33a8"
|
||||||
|
theme[process_start]="#50fa7b"
|
||||||
|
theme[process_mid]="#59b690"
|
||||||
|
theme[process_end]="#6272a4"
|
||||||
Loading…
Add table
Add a link
Reference in a new issue