television: add themes option
Add a `themes` option to the television module, allowing users to define
custom themes that are written to `$XDG_CONFIG_HOME/television/themes/`
as individual TOML files. This follows the same pattern used by the
halloy and helix modules.
💘 Generated with Crush
Assisted-by: Crush:glm-5.2
This commit is contained in:
committed by
Austin Horstman
parent
eb0eb170bb
commit
c187002980
@@ -0,0 +1,12 @@
|
||||
{ config, ... }:
|
||||
{
|
||||
time = "2026-06-16T00:27:55+00:00";
|
||||
condition = config.programs.television.enable;
|
||||
message = ''
|
||||
A new option is available: `programs.television.themes`.
|
||||
|
||||
This option allows you to define custom themes that will be written to
|
||||
`$XDG_CONFIG_HOME/television/themes/''${name}.toml`. Each theme accepts
|
||||
either inline TOML content or a path to a theme file.
|
||||
'';
|
||||
}
|
||||
@@ -84,6 +84,47 @@ in
|
||||
|
||||
};
|
||||
|
||||
themes = lib.mkOption {
|
||||
type = lib.types.attrsOf (
|
||||
lib.types.oneOf [
|
||||
tomlFormat.type
|
||||
lib.types.lines
|
||||
lib.types.path
|
||||
]
|
||||
);
|
||||
default = { };
|
||||
example = {
|
||||
default = {
|
||||
border_fg = "bright-black";
|
||||
text_fg = "bright-blue";
|
||||
dimmed_text_fg = "white";
|
||||
input_text_fg = "bright-red";
|
||||
result_count_fg = "bright-red";
|
||||
result_name_fg = "bright-blue";
|
||||
result_line_number_fg = "bright-yellow";
|
||||
result_value_fg = "white";
|
||||
selection_fg = "bright-green";
|
||||
selection_bg = "bright-black";
|
||||
match_fg = "bright-red";
|
||||
preview_title_fg = "bright-magenta";
|
||||
channel_mode_fg = "black";
|
||||
channel_mode_bg = "green";
|
||||
remote_control_mode_fg = "black";
|
||||
remote_control_mode_bg = "yellow";
|
||||
action_picker_mode_fg = "black";
|
||||
action_picker_mode_bg = "magenta";
|
||||
send_to_channel_mode_fg = "cyan";
|
||||
};
|
||||
};
|
||||
description = ''
|
||||
Each theme is written to
|
||||
{file}`$XDG_CONFIG_HOME/television/themes/NAME.toml`.
|
||||
|
||||
See <https://alexpasmantier.github.io/television/user-guide/themes>
|
||||
for more information.
|
||||
'';
|
||||
};
|
||||
|
||||
enableBashIntegration = lib.hm.shell.mkBashIntegrationOption { inherit config; };
|
||||
enableZshIntegration = lib.hm.shell.mkZshIntegrationOption { inherit config; };
|
||||
enableFishIntegration = lib.hm.shell.mkFishIntegrationOption { inherit config; };
|
||||
@@ -105,6 +146,18 @@ in
|
||||
source = tomlFormat.generate "television-${name}-channels" value;
|
||||
}
|
||||
) cfg.channels)
|
||||
(lib.mapAttrs' (
|
||||
name: value:
|
||||
lib.nameValuePair "television/themes/${name}.toml" {
|
||||
source =
|
||||
if lib.isString value then
|
||||
pkgs.writeText "television-theme-${name}" value
|
||||
else if lib.hm.strings.isPathLike value then
|
||||
value
|
||||
else
|
||||
tomlFormat.generate "television-theme-${name}" value;
|
||||
}
|
||||
) cfg.themes)
|
||||
];
|
||||
|
||||
programs.bash.initExtra = lib.mkIf cfg.enableBashIntegration ''
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
{
|
||||
television-basic-config = ./basic-config.nix;
|
||||
television-themes-config = ./themes-config.nix;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
action_picker_mode_bg = "magenta"
|
||||
action_picker_mode_fg = "black"
|
||||
border_fg = "bright-black"
|
||||
channel_mode_bg = "green"
|
||||
channel_mode_fg = "black"
|
||||
dimmed_text_fg = "white"
|
||||
input_text_fg = "bright-red"
|
||||
match_fg = "bright-red"
|
||||
preview_title_fg = "bright-magenta"
|
||||
remote_control_mode_bg = "yellow"
|
||||
remote_control_mode_fg = "black"
|
||||
result_count_fg = "bright-red"
|
||||
result_line_number_fg = "bright-yellow"
|
||||
result_name_fg = "bright-blue"
|
||||
result_value_fg = "white"
|
||||
selection_bg = "bright-black"
|
||||
selection_fg = "bright-green"
|
||||
send_to_channel_mode_fg = "cyan"
|
||||
text_fg = "bright-blue"
|
||||
@@ -0,0 +1,39 @@
|
||||
{ config, ... }:
|
||||
{
|
||||
programs.television = {
|
||||
enable = true;
|
||||
package = config.lib.test.mkStubPackage { name = "television"; };
|
||||
|
||||
settings = {
|
||||
ui.theme = "default";
|
||||
};
|
||||
|
||||
themes.default = {
|
||||
border_fg = "bright-black";
|
||||
text_fg = "bright-blue";
|
||||
dimmed_text_fg = "white";
|
||||
input_text_fg = "bright-red";
|
||||
result_count_fg = "bright-red";
|
||||
result_name_fg = "bright-blue";
|
||||
result_line_number_fg = "bright-yellow";
|
||||
result_value_fg = "white";
|
||||
selection_fg = "bright-green";
|
||||
selection_bg = "bright-black";
|
||||
match_fg = "bright-red";
|
||||
preview_title_fg = "bright-magenta";
|
||||
channel_mode_fg = "black";
|
||||
channel_mode_bg = "green";
|
||||
remote_control_mode_fg = "black";
|
||||
remote_control_mode_bg = "yellow";
|
||||
action_picker_mode_fg = "black";
|
||||
action_picker_mode_bg = "magenta";
|
||||
send_to_channel_mode_fg = "cyan";
|
||||
};
|
||||
};
|
||||
|
||||
nmt.script = ''
|
||||
assertFileContent \
|
||||
home-files/.config/television/themes/default.toml \
|
||||
${./themes-config-expected.toml}
|
||||
'';
|
||||
}
|
||||
Reference in New Issue
Block a user