|
| 1 | +<div align="center"> |
| 2 | + <h1> Docker Plugin</h1> |
| 3 | + <p>Displays running Docker container statistics in xfetch.</p> |
| 4 | +</div> |
| 5 | + |
| 6 | +<br> |
| 7 | + |
| 8 | +<div align="center"> |
| 9 | + <table> |
| 10 | + <tr> |
| 11 | + <td><strong>Kind</strong></td> |
| 12 | + <td><code>info_provider</code></td> |
| 13 | + </tr> |
| 14 | + <tr> |
| 15 | + <td><strong>Binary</strong></td> |
| 16 | + <td><code>xfetch-plugin-docker</code></td> |
| 17 | + </tr> |
| 18 | + <tr> |
| 19 | + <td><strong>Dependencies</strong></td> |
| 20 | + <td><code>docker</code> CLI</td> |
| 21 | + </tr> |
| 22 | + </table> |
| 23 | +</div> |
| 24 | + |
| 25 | +<br> |
| 26 | + |
| 27 | +<h2>Build</h2> |
| 28 | + |
| 29 | +<pre><code>cargo build --release --manifest-path plugins/docker/Cargo.toml</code></pre> |
| 30 | + |
| 31 | +<p>The binary will be created at:</p> |
| 32 | + |
| 33 | +<pre><code>plugins/docker/target/release/xfetch-plugin-docker</code></pre> |
| 34 | + |
| 35 | +<h2>Install</h2> |
| 36 | + |
| 37 | +<pre><code>xfetch plugin install ./plugins/docker</code></pre> |
| 38 | + |
| 39 | +<h2>Configuration</h2> |
| 40 | + |
| 41 | +<p>Add the plugin to your <code>config.jsonc</code>:</p> |
| 42 | + |
| 43 | +<pre><code class="language-jsonc">{ |
| 44 | + "info_plugins": [ |
| 45 | + { |
| 46 | + "plugin": "docker" |
| 47 | + } |
| 48 | + ], |
| 49 | + "modules": [ |
| 50 | + "os", |
| 51 | + "kernel", |
| 52 | + "plugin:docker", |
| 53 | + "shell", |
| 54 | + "cpu", |
| 55 | + "memory" |
| 56 | + ] |
| 57 | +}</code></pre> |
| 58 | + |
| 59 | +<p>The docker plugin does not require any arguments. It reads directly from the <code>docker</code> CLI.</p> |
| 60 | + |
| 61 | +<h2>Output</h2> |
| 62 | + |
| 63 | +<table> |
| 64 | + <thead> |
| 65 | + <tr> |
| 66 | + <th>State</th> |
| 67 | + <th>Example Output</th> |
| 68 | + </tr> |
| 69 | + </thead> |
| 70 | + <tbody> |
| 71 | + <tr> |
| 72 | + <td>Daemon running with containers</td> |
| 73 | + <td><pre> Containers: 15 total<br> ▶ 3 running<br> ⏸ 1 paused<br> ⏹ 11 stopped</pre></td> |
| 74 | + </tr> |
| 75 | + <tr> |
| 76 | + <td>Docker installed but daemon not running</td> |
| 77 | + <td><code> Docker: daemon not running</code></td> |
| 78 | + </tr> |
| 79 | + <tr> |
| 80 | + <td>Docker CLI not found</td> |
| 81 | + <td><code> Docker: not found</code></td> |
| 82 | + </tr> |
| 83 | + </tbody> |
| 84 | +</table> |
| 85 | + |
| 86 | +<h2>How It Works</h2> |
| 87 | + |
| 88 | +<ol> |
| 89 | + <li>xfetch sends a JSON request with <code>kind: "info_provider"</code>.</li> |
| 90 | + <li>The plugin runs <code>docker info --format '{{.Containers}} {{.ContainersRunning}} ...'</code>.</li> |
| 91 | + <li>The plugin returns a JSON response with the formatted lines.</li> |
| 92 | + <li>xfetch displays them under the <code>plugin:docker</code> module key.</li> |
| 93 | +</ol> |
| 94 | + |
| 95 | +<h2>Protocol</h2> |
| 96 | + |
| 97 | +<h3>Request</h3> |
| 98 | + |
| 99 | +<pre><code class="language-json">{ |
| 100 | + "version": 1, |
| 101 | + "kind": "info_provider", |
| 102 | + "args": null |
| 103 | +}</code></pre> |
| 104 | + |
| 105 | +<h3>Response</h3> |
| 106 | + |
| 107 | +<pre><code class="language-json">{ |
| 108 | + "lines": [ |
| 109 | + " Containers: 15 total", |
| 110 | + " ▶ 3 running", |
| 111 | + " ⏸ 1 paused", |
| 112 | + " ⏹ 11 stopped" |
| 113 | + ] |
| 114 | +}</code></pre> |
| 115 | + |
| 116 | +<h2>Notes</h2> |
| 117 | + |
| 118 | +<ul> |
| 119 | + <li>Requires the <code>docker</code> CLI to be installed and available in <code>PATH</code>.</li> |
| 120 | + <li>If the Docker daemon is not running, the plugin reports it gracefully.</li> |
| 121 | + <li>No authentication or configuration is needed.</li> |
| 122 | +</ul> |
0 commit comments