| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
parent directory.. | ||||
xfetch plugins are standalone executables that communicate with the core via stdin/stdout using a JSON protocol. This document describes the protocol, the required binary naming conventions, and best practices for creating your own plugin.
The shared protocol crate is maintained in xfetch-cli/api.
Official plugins and third-party plugins are expected to use this crate instead of reimplementing protocol parsing manually.
The plugin binary must follow this naming convention so xfetch can discover it:
xfetch-plugin-<name>
| Platform | Example |
|---|---|
| Linux / macOS | xfetch-plugin-animate-logo |
| Windows | xfetch-plugin-animate-logo.exe |
The Cargo.toml name field should follow the same convention:
[package] name = "xfetch-plugin-<name>" version = "0.1.0" edition = "2024"
When running a plugin, xfetch searches for the binary in the following order:
The plugin protocol uses JSON over stdin/stdout. The plugin reads exactly one JSON object from stdin and writes exactly one JSON object to stdout.
{
"version": 1,
"kind": "<plugin_kind>",
"lines": ["line 1", "line 2"],
"frames": [
["frame 1 line 1", "frame 1 line 2"],
["frame 2 line 1", "frame 2 line 2"]
],
"args": {
"fps": 12,
"duration_ms": 1200,
"loop": false,
"style": "sweep"
}
}
| Field | Type | Description |
|---|---|---|
| version | u32 | Protocol version (currently 1). |
| kind | string | Plugin type. Currently only "logo_animation" is supported. |
| lines | array[string] | Logo ASCII art, one line per element. |
| frames | array[array[string]] or null | Optional pre-loaded frame sets for frame-based animation. |
| args | object | Plugin-specific arguments from the user config. |
{
"frames": [
{
"delay_ms": 83,
"lines": ["colored line 1", "colored line 2"]
}
]
}
| Field | Type | Description |
|---|---|---|
| frames | array[Frame] | Array of animation frames (required). Must not be empty. |
| Field | Type | Description |
|---|---|---|
| delay_ms | u64 | Milliseconds to display this frame before advancing. |
| lines | array[string] | Frame content (may include ANSI escape codes for color). |
The animate-logo plugin is the reference implementation. Its source is at plugins/animate-logo/src/main.rs.
Minimal plugin skeleton in Rust using the shared crate:
use xfetch_plugin_api::{
read_info_plugin_args_or_default,
write_info_lines,
};
#[derive(Debug, Default, serde::Deserialize)]
struct PluginArgs {}
fn main() {
let _args = match read_info_plugin_args_or_default::<PluginArgs>() {
Ok(value) => value,
Err(err) => {
eprintln!("{}", err);
std::process::exit(1);
}
};
if let Err(err) = write_info_lines(vec!["hello from plugin".to_string()]) {
eprintln!("{}", err);
std::process::exit(1);
}
}
Test your plugin manually by writing a request file and piping it:
echo '{"version":1,"kind":"logo_animation","lines":["hello"],"args":{"fps":12}}' \
| ./target/release/xfetch-plugin-my-plugin
You can also install it locally and test it with xfetch:
xfetch plugin install my-plugin xfetch
| Back | FazBrowse Home | New Git URL |