Skip to content

Commit

Permalink
lsd: add support for icons.yaml
Browse files Browse the repository at this point in the history
This update introduces support for icons.yaml in the lsd module,
enhancing the customization options for file icons.

Co-authored-by: pancho horrillo <[email protected]>
  • Loading branch information
nilp0inter and panchoh authored Jan 21, 2025
1 parent 9786661 commit 0b8df9e
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 0 deletions.
28 changes: 28 additions & 0 deletions modules/programs/lsd.nix
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,30 @@ in {
automatically set to `"custom"`.
'';
};

icons = mkOption {
type = yamlFormat.type;
default = { };
example = {
name = {
".trash" = "";
".cargo" = "";
};
extension = {
"go" = "";
"hs" = "";
};
filetype = {
"dir" = "📂";
"file" = "📄";
};
};
description = ''
Configuration written to {file}`$XDG_CONFIG_HOME/lsd/icons.yaml`. See
<https://github.com/lsd-rs/lsd?tab=readme-ov-file#icon-theme-file-content> for
details.
'';
};
};

config = mkIf cfg.enable {
Expand All @@ -91,6 +115,10 @@ in {
source = yamlFormat.generate "lsd-colors" cfg.colors;
};

xdg.configFile."lsd/icons.yaml" = mkIf (cfg.icons != { }) {
source = yamlFormat.generate "lsd-icons" cfg.icons;
};

xdg.configFile."lsd/config.yaml" = mkIf (cfg.settings != { }) {
source = yamlFormat.generate "lsd-config" cfg.settings;
};
Expand Down
9 changes: 9 additions & 0 deletions tests/modules/programs/lsd/example-icons-expected.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
extension:
go:
hs:
filetype:
dir: 📂
file: 📄
name:
.cargo:
.trash:
18 changes: 18 additions & 0 deletions tests/modules/programs/lsd/example-settings.nix
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,37 @@ with lib;
large = "dark_yellow";
};
};
icons = {
name = {
".trash" = "";
".cargo" = "";
};
extension = {
"go" = "";
"hs" = "";
};
filetype = {
"dir" = "📂";
"file" = "📄";
};
};
};

test.stubs.lsd = { };

nmt.script = ''
assertFileExists home-files/.config/lsd/config.yaml
assertFileExists home-files/.config/lsd/colors.yaml
assertFileExists home-files/.config/lsd/icons.yaml
assertFileContent \
home-files/.config/lsd/config.yaml \
${./example-settings-expected.yaml}
assertFileContent \
home-files/.config/lsd/colors.yaml \
${./example-colors-expected.yaml}
assertFileContent \
home-files/.config/lsd/icons.yaml \
${./example-icons-expected.yaml}
'';
};
}

0 comments on commit 0b8df9e

Please sign in to comment.