Skip to content

Commit

Permalink
feat(shell): add dynamic disk display and image size for neofetch
Browse files Browse the repository at this point in the history
  • Loading branch information
zakuciael committed Jan 2, 2025
1 parent c8685b6 commit dc73bb1
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions modules/shell/neofetch.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,25 @@
...
}:
let
inherit (lib) mkIf mkEnableOption;
inherit (lib)
mkIf
mkEnableOption
attrNames
concatMapStringsSep
length
;

cfg = config.modules.shell.neofetch;
imageFile = dotfiles.neofetch."nixos.png".source;
templateFile = dotfiles.neofetch."config.conf".source;

disks = attrNames config.fileSystems;
lines = 20 + (length disks);
lineHeight = 20;
configFile = pkgs.runCommand "config.conf" { } ''
substitute "${templateFile}" "$out" \
--replace-fail "{{% DISK_SHOW %}}" "'/'" \
--replace-fail "{{% IMAGE_SIZE %}}" "400px" \
--replace-fail "{{% DISK_SHOW %}}" "${concatMapStringsSep " " (disk: "'${disk}'") disks}" \
--replace-fail "{{% IMAGE_SIZE %}}" "${builtins.toString (lines * lineHeight)}px" \
--replace-fail "{{% IMAGE_SOURCE %}}" "${imageFile}"
'';
neofetchPkg = pkgs.neofetch.overrideAttrs {
Expand Down

0 comments on commit dc73bb1

Please sign in to comment.