Help with programs.yazi.theme configuration

I am trying to use home-manager to configure my yazi theme.toml file.

The example given here in the home-manager Appendix is:

{
  filetype = {
    rules = [
      { fg = "#7AD9E5"; mime = "image/*"; }
      { fg = "#F3D398"; mime = "video/*"; }
      { fg = "#F3D398"; mime = "audio/*"; }
      { fg = "#CD9EFC"; mime = "application/x-bzip"; }
    ];
  };
}

which is supposed to yield a theme.toml file something like this:

[filetype]
rules = [
	{ mime = "image/*", fg = "yellow" },
	{ mime = "{audio,video}/*", fg = "magenta" },

What I need is to create a theme.toml that looks like this:

[status]
progress_label  = { bold = true }
progress_normal = { fg = "blue", bg = "black" }
progress_error  = { fg = "red", bg = "black" }

but I can’t seem to come up with the correct syntax for the home-manager option. I seem that have wandered into brace/bracket/quotation hell. Could someone please let me know how to do this? Greatly appreciated.

What you want can be written like this:

  programs.yazi.theme = {
    status = {
      progress_error = {
        bg = "black";
        fg = "red";
      };
      progress_label = {
        bold = true;
      };
      progress_normal = {
        bg = "black";
        fg = "blue";
      };
    };
  };

Alternatively, you can just put your settings in a toml file and import it:

{ lib, ... }:
{
  programs.yazi.theme = lib.importTOML ./yazi-theme.toml;
}
# yazi-theme.toml
[status]
progress_label  = { bold = true }
progress_normal = { fg = "blue", bg = "black" }
progress_error  = { fg = "red", bg = "black" }

PS: the home-manager example results in the following toml file:

[[filetype.rules]]
fg = "#7AD9E5"
mime = "image/*"

[[filetype.rules]]
fg = "#F3D398"
mime = "video/*"

[[filetype.rules]]
fg = "#F3D398"
mime = "audio/*"

[[filetype.rules]]
fg = "#CD9EFC"
mime = "application/x-bzip"

Thanks for the quick and detailed reply. I did try exactly what you recommended, but the resulting theme.toml file is not formatted like the default yazi theme.toml, and the changes I am making aren’t producing any results. I am wondering if the home-manager module is not working properly.

Can you post what the expected and result files are? and which changes are not working, exactly?

It appears to be my mistake. I was trying to change the fg color of the size and percentage pill areas in the status bar, which appears not to be possible. Apparently, it just used the bg of mode_normal as the fg color of these areas. I thought it was because I had not formed my home-manager options correctly.

Do you know of a way to change the fg of these areas to be different from the bg color of mode_normal?

I don’t think it’s currently possible at the moment, at least not without modifying the status bar’s lua config according to this issue. However, I do think that theming is planned to be improved in the future, which is currently being tracked in the feature requests page.

Excellent. Thank you for your informative replies.

It’s obviously just a small issue that I can work around for now. Far outweighed by the overall awesomeness of yazi.

1 Like