Skip to content

feat: add per-module label, value and command overrides - #6

Merged
Andrew-Velox merged 2 commits into
mainfrom
feat/module-overrides
Oct 11, 2026
Merged

Andrew-Velox merged 2 commits into
mainfrom
feat/module-overrides

Conversation

@Andrew-Velox

Copy link
Copy Markdown
Owner

Fixes #5

Adds the fastfetch-style overrides asked for in #5: rename a built-in row, replace its reading with a string, or take its value from a command.

Config

modules = ["os", "kernel", "uptime", "custom", "shell"]

[overrides.os]
label = "Distro"                 # rename only

[overrides.kernel]
value = "my-own-kernel 1.0"      # fixed text instead of the reading

[overrides.uptime]
label = "Up"
command = "uptime -p"            # first line of the output

[[custom]]
label = "Public IP"
command = "curl -s --max-time 1 ifconfig.me"   # custom rows take a command too

New key: command_timeout (default 1s, clamped to 0.1-10).

Behaviour

  • label is display-only. The row keeps its icon, its place and its --live updates. iconic and tree print no names, so a rename does not show there.
  • value / command replace the row's figures and bars with plain text, and the row is excluded from --live refresh so it is not overwritten.
  • A module the machine cannot read (e.g. battery on a desktop) still shows the user's text if they override it.
  • Commands run once at startup through sh -c with the user's privileges, all started together, so the wait is the slowest one rather than the sum. Only the first non-empty line is used, with control characters stripped. Nothing printed, or longer than command_timeout, leaves the row out.
  • Mistakes (unknown module, value with command, empty table, empty label, overriding colors/custom) are reported at load, and config errors now include the line number.
  • Existing configs are unchanged: custom = [{ label, value }] parses as before.

Implementation

  • src/rows.rs: Source, CustomRow, Override, validated at parse time.
  • src/fetch/command.rs: the one process runner (deadline, process group kill, output cap), now shared with the version probes in detail.rs.
  • Item gains a private display name next to its identity label; styles use it where they print a label.
  • fetch::gather plans the rows first so every command can start before any is waited on.

Testing

  • 435 tests pass (428 with --no-default-features), including a width sweep of long custom names across every style and tests that a refresh never overwrites an override.
  • clippy -D warnings and cargo doc -D warnings clean on 1.98.1 and a recent nightly; macOS targets compile.
  • Run by hand with a real config in the classic, boxed, card and minimal styles, including a command that exceeds the timeout.

Rename a built-in row, replace its reading with fixed text, or take its
value from a shell command, under [overrides.<module>]. Custom rows can
now take a command as well as a value.

- label is display-only: a row keeps its icon, place and live updates
- value/command replace the row's figures with plain text, and the row
  is no longer refreshed by --live
- commands run once at startup through sh -c, all together, so the wait
  is the slowest one; nothing printed or past command_timeout (default
  1s) leaves the row out
- output is the first non-empty line with control characters removed
- config errors now say which line the mistake is on
- one shared process runner for these commands and the version probes

Fixes #5
my_github_cli reports the shields.io badges in the README as broken links
and fails the check. The job is skipped until the tool is updated.
@Andrew-Velox
Andrew-Velox merged commit ecc476e into main Oct 11, 2026
3 checks passed
@Andrew-Velox
Andrew-Velox deleted the feat/module-overrides branch October 11, 2026 21:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Please add custom module label overrides.

1 participant