Versão 0.6.0: saúde do disco no estilo do CrystalDiskInfo e nova logo
Release / Cria a release (push) Canceled after 0s
Release / CLI (linux-aarch64) (push) Canceled after 0s
Release / CLI (linux-x86_64) (push) Canceled after 0s
Release / CLI (macos-aarch64) (push) Canceled after 0s
Release / CLI (macos-x86_64) (push) Canceled after 0s
Release / CLI (windows-x86_64) (push) Canceled after 0s
Release / App desktop (linux-x86_64) (push) Canceled after 0s
Release / App desktop (macos-aarch64) (push) Canceled after 0s
Release / App desktop (macos-x86_64) (push) Canceled after 0s
Release / App desktop (windows-x86_64) (push) Canceled after 0s
Release / Publica a release (push) Canceled after 0s

SMART completo (estado com % de vida útil, temperatura, horas e vezes
ligado, total lido/gravado, ficha do dispositivo e tabela de atributos
ATA e NVMe), leitura pelo disco que contém a partição e comando
`guara health`. Nova logo: a cabeça do guará recortada das trilhas de um
disco, nas cores do app.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Lucas RayanandClaude Opus 5.5 committed 2026-10-18 22:05:48 -03:00
1 parent f65e7ae615
commit c3b5f79009
22 files changed
+638 -139

No files matched your search

+11
View File
@@ -2,6 +2,17 @@
Formato baseado em [Keep a Changelog](https://keepachangelog.com/pt-BR/1.1.0/); versões seguem SemVer.
## [0.6.0] - 2026-10-18
### Adicionado
- **Saúde do disco no estilo do CrystalDiskInfo:** a tela do dispositivo mostra o estado (Bom, Atenção, Ruim) com a % de vida útil restante em SSD, temperatura, horas ligado, vezes ligado, total lido e total gravado. Também traz a ficha do dispositivo (modelo, firmware, nº de série, interface, modo de transferência, capacidade, rotação, formato e recursos como TRIM) e a tabela completa de atributos SMART, com ID, valor atual, pior, limite e bruto, e um indicador por atributo. Funciona com discos ATA/SATA e NVMe (nos NVMe, os campos do log de saúde viram a tabela).
- **Partições:** ao abrir uma partição (`/dev/sda1`, `/dev/nvme0n1p2`, `/dev/disk2s1`), o SMART é lido do disco que a contém, e a tela avisa isso.
- **Comando `guara health`** no terminal, com saída legível ou `--json`.
### Alterado
- Um atributo SMART com valor normalizado no limite de falha (ou abaixo dele) agora marca o disco como "Ruim", mesmo que a autoavaliação geral ainda passe.
- **Nova logo:** a cabeça do lobo-guará recortada das trilhas de um disco, inteiras de um lado (recuperado) e quebradas do outro (perdido), nas cores do app. Na interface ela acompanha o tema escolhido (claro ou escuro).
## [0.5.0] - 2026-10-18
### Adicionado
Generated
+2 -2
View File
@@ -317,7 +317,7 @@ dependencies = [
[[package]]
name = "guara-cli"
version = "0.5.0"
version = "0.6.0"
dependencies = [
"clap",
"ctrlc",
@@ -329,7 +329,7 @@ dependencies = [
[[package]]
name = "guara-core"
version = "0.5.0"
version = "0.6.0"
dependencies = [
"flate2",
"image",
+1 -1
View File
@@ -3,7 +3,7 @@ resolver = "2"
members = ["crates/guara-core", "crates/guara-cli"]
[workspace.package]
version = "0.5.0"
version = "0.6.0"
edition = "2021"
license = "MIT OR Apache-2.0"
repository = "https://github.com/lucasrguerra/guara"
+7
View File
@@ -41,6 +41,7 @@ Ler discos brutos exige privilégios: **administrador** (Windows), `sudo` (Linux
```bash
sudo guara devices # discos e pendrives (avisa TRIM e volumes montados)
sudo guara inspect /dev/sdb # partições, espaço não particionado, cifragem
sudo guara health /dev/sdb # saúde do disco (SMART), requer smartmontools
sudo guara scan /dev/sdb --session s.json --list # varredura profunda
sudo guara scan /dev/sdb --quick # só metadados (segundos)
guara scan disco.img --category image,document --min-confidence medium
@@ -117,6 +118,12 @@ Veja [CONTRIBUTING.md](CONTRIBUTING.md). Versões seguem [SemVer](https://semver
[MIT](LICENSE-MIT) ou [Apache-2.0](LICENSE-APACHE), à sua escolha.
## Novidades da 0.6.0
- Saúde do disco completa, no estilo do CrystalDiskInfo: estado com % de vida útil, temperatura, horas e vezes ligado, total lido e gravado, ficha do dispositivo (modelo, firmware, interface, modo de transferência, rotação, recursos) e a tabela inteira de atributos SMART (ATA e NVMe).
- Novo comando `guara health` no terminal.
- Nova logo: a cabeça do guará recortada das trilhas de um disco.
## Novidades da 0.5.0
- Visualizador de bancos SQLite com recuperação de linhas apagadas.
+1 -1
View File
@@ -3,7 +3,7 @@
[package]
name = "guara-gui"
description = "Guará: interface gráfica de recuperação de arquivos"
version = "0.5.0"
version = "0.6.0"
edition = "2021"
license = "MIT OR Apache-2.0"
repository = "https://github.com/lucasrguerra/guara"
Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 26 KiB

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 123 KiB

After

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 455 KiB

After

Width:  |  Height:  |  Size: 64 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 455 KiB

After

Width:  |  Height:  |  Size: 66 KiB

+1 -1
View File
@@ -1,7 +1,7 @@
{
"$schema": "https://schema.tauri.app/config/2",
"productName": "Guara",
"version": "0.5.0",
"version": "0.6.0",
"identifier": "dev.guara.app",
"build": {
"frontendDist": "../ui"
+22
View File
@@ -494,3 +494,25 @@ dialog.lightbox[open] { display: grid; }
.xp-tiles { display: grid; grid-template-columns: repeat(3, 1fr); width: 100%; height: 100%; }
.xp-tiles img { width: 100%; height: 100%; display: block; }
.xp-pin { position: absolute; width: 14px; height: 14px; margin: -7px 0 0 -7px; border-radius: 50%; background: #0f8f8f; border: 3px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.4); }
/* saúde do disco (SMART) */
.h-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
.h-tile { background: var(--surface); border-radius: 14px; box-shadow: var(--shadow); padding: 12px 14px; display: flex; flex-direction: column; gap: 2px; }
.h-tile small { color: var(--text-3); font-size: 12px; }
.h-tile b { font-size: 18px; font-variant-numeric: tabular-nums; }
.h-tile.warning b { color: var(--warn); } .h-tile.failing b { color: var(--bad); }
.h-status.ok { background: var(--ok-soft); } .h-status.ok b { color: var(--ok); }
.h-status.warning { background: var(--warn-soft); } .h-status.failing { background: var(--bad-soft); }
.h-status b span { font-weight: 500; opacity: .8; }
.h-info { margin-top: 14px; background: var(--surface); border-radius: 14px; box-shadow: var(--shadow); padding: 14px 16px; }
.h-scroll { overflow-x: auto; background: var(--surface); border-radius: 14px; box-shadow: var(--shadow); }
.h-table { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
.h-table th { text-align: left; color: var(--text-3); font-weight: 500; padding: 8px 10px; border-bottom: 1px solid var(--line, rgba(127,127,127,.2)); white-space: nowrap; }
.h-table td { padding: 6px 10px; border-bottom: 1px solid var(--line, rgba(127,127,127,.12)); white-space: nowrap; }
.h-table tr:last-child td { border-bottom: 0; }
.h-table .dim { color: var(--text-3); }
.h-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--ok); }
.h-dot.warning { background: var(--warn); } .h-dot.failing { background: var(--bad); }
/* logo inline: segue o tema escolhido no app, não o do sistema */
.logo .a { stroke: var(--accent); } .logo .b { stroke: var(--accent-2); } .logo .t { fill: var(--text); }
+36 -5
View File
@@ -287,15 +287,46 @@ async function openDevice(d) {
rpc('health', { path: d.path }).then((h) => { if (S.device === d) { S.health = h; paintHealth(); } }).catch(() => {});
}
const HEALTH_WORD = { ok: 'Bom', warning: 'Atenção', failing: 'Ruim' };
function paintHealth() {
const el = $('#healthArea');
const h = S.health;
if (!el || !h || !h.available) { if (el) el.innerHTML = ''; return; }
if (!el || !h) { if (el) el.innerHTML = ''; return; }
if (!h.available) {
el.innerHTML = `<div class="section"><h2>Saúde do disco</h2><p class="sub">${esc(h.summary)}</p></div>`;
return;
}
const bad = h.status === 'failing' || h.status === 'warning';
const rows = (h.details || []).filter(([k]) => bad || ['Modelo', 'Horas ligado', 'Temperatura'].includes(k)).map(([k, v]) => `<dt>${esc(k)}</dt><dd>${esc(v)}</dd>`).join('');
el.innerHTML = `<div class="notice ${h.status === 'failing' ? 'bad' : h.status === 'warning' ? '' : 'info'}">${warnSvg}<div><b>${esc(h.summary)}</b>
${rows ? `<dl class="kv" style="margin-top:6px">${rows}</dl>` : ''}${(h.advice || []).map((a) => `<div style="margin-top:6px">${esc(a)}</div>`).join('')}
${bad ? '<div class="row" style="margin-top:8px"><button class="btn sm primary" id="healthImg">Criar a imagem primeiro</button></div>' : ''}</div></div>`;
const fmtN = (n) => Number(n).toLocaleString(LOC());
const tile = (label, value, cls = '') => value == null ? '' : `<div class="h-tile ${cls}"><small>${label}</small><b>${value}</b></div>`;
const temp = h.temperature_c;
const tiles = [
`<div class="h-tile h-status ${esc(h.status)}"><small>Estado</small><b>${HEALTH_WORD[h.status] || '?'}${h.health_pct != null ? ` <span>${h.health_pct}%</span>` : ''}</b></div>`,
tile('Temperatura', temp == null ? null : `${temp} °C`, temp >= 60 ? 'failing' : temp >= 50 ? 'warning' : ''),
tile('Horas ligado', h.power_on_hours == null ? null : `${fmtN(h.power_on_hours)} h`),
tile('Vezes ligado', h.power_cycles == null ? null : fmtN(h.power_cycles)),
tile('Total lido', h.host_reads == null ? null : human(h.host_reads)),
tile('Total gravado', h.host_writes == null ? null : human(h.host_writes)),
].join('');
const info = (h.info || []).map(([k, v]) => `<dt>${esc(k)}</dt><dd>${esc(v)}</dd>`).join('');
const dash = (x) => x == null ? '<span class="dim">–</span>' : x;
const attrs = h.attributes || [];
const table = attrs.length ? `<details class="adv h-attrs"${bad ? ' open' : ''}><summary>Atributos SMART (${attrs.length})</summary>
<div class="h-scroll"><table class="h-table"><thead><tr><th></th><th>ID</th><th>Atributo</th><th>Atual</th><th>Pior</th><th>Limite</th><th>Bruto</th></tr></thead><tbody>
${attrs.map((a) => `<tr><td><span class="h-dot ${esc(a.status)}" title="${HEALTH_WORD[a.status] || ''}"></span></td><td class="mono">${esc(a.id)}</td><td class="mono">${esc(a.name)}</td><td>${dash(a.value)}</td><td>${dash(a.worst)}</td><td>${dash(a.thresh)}</td><td class="mono">${esc(a.raw)}</td></tr>`).join('')}
</tbody></table></div></details>` : '';
const scope = h.partition ? `<p class="sub">O SMART é do disco inteiro: os dados abaixo são de <span class="mono">${esc(h.disk)}</span>, que contém <span class="mono">${esc(h.partition)}</span>.</p>` : '';
// o que motivou o alerta (os campos da ficha já aparecem abaixo)
const known = new Set(['Modelo', 'Nº de série', 'Horas ligado', 'Temperatura', 'Autoavaliação SMART', 'Vida útil usada']);
const why = (h.details || []).filter(([k]) => !known.has(k)).map(([k, v]) => `<dt>${esc(k)}</dt><dd>${esc(v)}</dd>`).join('');
el.innerHTML = `${bad ? `<div class="notice ${h.status === 'failing' ? 'bad' : ''}">${warnSvg}<div><b>${esc(h.summary)}</b>
${why ? `<dl class="kv" style="margin-top:6px">${why}</dl>` : ''}
${(h.advice || []).map((a) => `<div style="margin-top:6px">${esc(a)}</div>`).join('')}
<div class="row" style="margin-top:8px"><button class="btn sm primary" id="healthImg">Criar a imagem primeiro</button></div></div></div>` : ''}
<div class="section"><h2>Saúde do disco</h2>${scope}
<div class="h-tiles">${tiles}</div>
${info ? `<dl class="kv h-info">${info}</dl>` : ''}${table}</div>`;
$('#healthImg')?.addEventListener('click', startImage);
}
+1 -1
View File
@@ -1 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 160 100" role="img" aria-label="Guará"><polygon points="146.58,7.00 144.87,10.85 147.43,12.13" fill="#38d3c1" stroke="#38d3c1" stroke-width="0.25" stroke-linejoin="round"/><polygon points="131.94,67.89 135.88,72.47 135.24,69.04" fill="#0a424e" stroke="#0a424e" stroke-width="0.25" stroke-linejoin="round"/><polygon points="112.13,68.19 116.20,66.47 107.81,62.69" fill="#23b8aa" stroke="#23b8aa" stroke-width="0.25" stroke-linejoin="round"/><polygon points="143.15,8.71 144.87,10.85 146.58,7.00" fill="#38d3c0" stroke="#38d3c0" stroke-width="0.25" stroke-linejoin="round"/><polygon points="101.86,14.48 105.07,14.27 104.21,11.27" fill="#2dc5b5" stroke="#2dc5b5" stroke-width="0.25" stroke-linejoin="round"/><polygon points="108.92,6.14 112.34,8.28 111.92,4.43" fill="#2dc5b5" stroke="#2dc5b5" stroke-width="0.25" stroke-linejoin="round"/><polygon points="37.51,61.88 38.06,58.55 35.26,59.42" fill="#16a69b" stroke="#16a69b" stroke-width="0.25" stroke-linejoin="round" fill-opacity="0.44" stroke-opacity="0.44"/><polygon points="51.64,65.75 54.46,64.96 52.55,62.38" fill="#16a79b" stroke="#16a79b" stroke-width="0.25" stroke-linejoin="round" fill-opacity="0.66" stroke-opacity="0.66"/><polygon points="46.20,62.56 49.71,66.06 50.53,62.99" fill="#1baea1" stroke="#1baea1" stroke-width="0.25" stroke-linejoin="round" fill-opacity="0.58" stroke-opacity="0.58"/><polygon points="48.26,63.58 45.03,60.36 44.41,64.13" fill="#12a298" stroke="#12a298" stroke-width="0.25" stroke-linejoin="round" fill-opacity="0.52" stroke-opacity="0.52"/><polygon points="61.85,68.19 62.92,72.99 65.81,67.07" fill="#13a398" stroke="#13a398" stroke-width="0.25" stroke-linejoin="round"/><polygon points="62.92,72.99 61.85,68.19 55.42,69.11" fill="#19ab9f" stroke="#19ab9f" stroke-width="0.25" stroke-linejoin="round"/><polygon points="38.33,89.93 36.63,88.22 36.63,89.93" fill="#0f9e94" stroke="#0f9e94" stroke-width="0.25" stroke-linejoin="round" fill-opacity="0.39" stroke-opacity="0.39"/><polygon points="98.42,72.35 97.37,66.47 91.80,72.47" fill="#a9f2e5" stroke="#a9f2e5" stroke-width="0.25" stroke-linejoin="round"/><polygon points="92.66,77.17 98.42,72.35 91.80,72.47" fill="#a6f2e5" stroke="#a6f2e5" stroke-width="0.25" stroke-linejoin="round"/><polygon points="98.42,72.35 92.66,77.17 100.36,80.17" fill="#aff3e7" stroke="#aff3e7" stroke-width="0.25" stroke-linejoin="round"/><polygon points="85.59,79.64 92.66,77.17 91.80,72.47" fill="#17a89c" stroke="#17a89c" stroke-width="0.25" stroke-linejoin="round"/><polygon points="92.66,77.17 99.65,82.45 100.36,80.17" fill="#1fb2a5" stroke="#1fb2a5" stroke-width="0.25" stroke-linejoin="round"/><polygon points="99.65,82.45 92.66,77.17 96.80,84.95" fill="#1db0a3" stroke="#1db0a3" stroke-width="0.25" stroke-linejoin="round"/><polygon points="133.31,53.64 131.39,55.35 133.74,59.63" fill="#109087" stroke="#109087" stroke-width="0.25" stroke-linejoin="round"/><polygon points="121.41,64.97 128.18,59.63 123.90,58.77" fill="#093f4a" stroke="#093f4a" stroke-width="0.25" stroke-linejoin="round"/><polygon points="108.07,68.61 112.13,68.19 107.81,62.69" fill="#1aaca0" stroke="#1aaca0" stroke-width="0.25" stroke-linejoin="round"/><polygon points="127.98,73.39 135.88,72.47 131.94,67.89" fill="#093c48" stroke="#093c48" stroke-width="0.25" stroke-linejoin="round"/><polygon points="127.98,73.39 124.18,72.59 121.76,80.81" fill="#093e49" stroke="#093e49" stroke-width="0.25" stroke-linejoin="round"/><polygon points="124.18,72.59 118.91,75.14 121.76,80.81" fill="#093f4b" stroke="#093f4b" stroke-width="0.25" stroke-linejoin="round"/><polygon points="143.15,8.71 140.16,10.63 144.87,10.85" fill="#33cdbb" stroke="#33cdbb" stroke-width="0.25" stroke-linejoin="round"/><polygon points="144.01,27.53 139.52,28.60 142.08,31.60" fill="#2cc3b3" stroke="#2cc3b3" stroke-width="0.25" stroke-linejoin="round"/><polygon points="128.18,59.63 134.60,61.77 133.74,59.63" fill="#0a414d" stroke="#0a414d" stroke-width="0.25" stroke-linejoin="round"/><polygon points="134.60,61.77 128.18,59.63 131.94,67.89" fill="#0a424e" stroke="#0a424e" stroke-width="0.25" stroke-linejoin="round"/><polygon points="109.35,9.56 108.92,6.14 106.57,8.71" fill="#30c9b8" stroke="#30c9b8" stroke-width="0.25" stroke-linejoin="round"/><polygon points="109.35,9.56 112.34,8.28 108.92,6.14" fill="#31cab9" stroke="#31cab9" stroke-width="0.25" stroke-linejoin="round"/><polygon points="104.21,11.27 109.35,9.56 106.57,8.71" fill="#31cab9" stroke="#31cab9" stroke-width="0.25" stroke-linejoin="round"/><polygon points="105.07,14.27 109.35,9.56 104.21,11.27" fill="#2fc7b6" stroke="#2fc7b6" stroke-width="0.25" stroke-linejoin="round"/><polygon points="112.34,8.28 114.48,8.28 111.92,4.43" fill="#2bc2b2" stroke="#2bc2b2" stroke-width="0.25" stroke-linejoin="round"/><polygon points="116.20,66.47 116.20,60.06 107.81,62.69" fill="#25baab" stroke="#25baab" stroke-width="0.25" stroke-linejoin="round"/><polygon points="106.78,53.75 110.63,53.64 108.92,46.79" fill=Line truncated
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" role="img" aria-label="Guará"><style>.a{stroke:#0f766e}.b{stroke:#14b8a6}.t{fill:#1d1d1f}@media (prefers-color-scheme:dark){.a{stroke:#2dd4bf}.b{stroke:#5eead4}.t{fill:#f5f5f7}}</style><defs><clipPath id="g-head"><path d="M50 95 C46 88 43 80 40 74 C33 70 25 64 22 56 L14 6 L36 30 C40 28 45 27 50 27 C55 27 60 28 64 30 L86 6 L78 56 C75 64 67 70 60 74 C57 80 54 88 50 95 Z"/></clipPath></defs><g clip-path="url(#g-head)" fill="none" stroke-width="4.2"><path class="a" d="M50 93A7 7 0 0 1 50 107"/><path class="b" d="M50 93A7 7 0 0 0 50 107" stroke-dasharray="3 3" stroke-dashoffset="0"/><path class="a" d="M50 86A14 14 0 0 1 50 114"/><path class="b" d="M50 86A14 14 0 0 0 50 114" stroke-dasharray="6 4" stroke-dashoffset="3"/><path class="a" d="M50 79A21 21 0 0 1 50 121"/><path class="b" d="M50 79A21 21 0 0 0 50 121" stroke-dasharray="9 5" stroke-dashoffset="6"/><path class="a" d="M50 72A28 28 0 0 1 50 128"/><path class="b" d="M50 72A28 28 0 0 0 50 128" stroke-dasharray="3 6" stroke-dashoffset="9"/><path class="a" d="M50 65A35 35 0 0 1 50 135"/><path class="b" d="M50 65A35 35 0 0 0 50 135" stroke-dasharray="6 3" stroke-dashoffset="12"/><path class="a" d="M50 58A42 42 0 0 1 50 142"/><path class="b" d="M50 58A42 42 0 0 0 50 142" stroke-dasharray="9 4" stroke-dashoffset="15"/><path class="a" d="M50 51A49 49 0 0 1 50 149"/><path class="b" d="M50 51A49 49 0 0 0 50 149" stroke-dasharray="3 5" stroke-dashoffset="18"/><path class="a" d="M50 44A56 56 0 0 1 50 156"/><path class="b" d="M50 44A56 56 0 0 0 50 156" stroke-dasharray="6 6" stroke-dashoffset="21"/><path class="a" d="M50 37A63 63 0 0 1 50 163"/><path class="b" d="M50 37A63 63 0 0 0 50 163" stroke-dasharray="9 3" stroke-dashoffset="24"/><path class="a" d="M50 30A70 70 0 0 1 50 170"/><path class="b" d="M50 30A70 70 0 0 0 50 170" stroke-dasharray="3 4" stroke-dashoffset="27"/><path class="a" d="M50 23A77 77 0 0 1 50 177"/><path class="b" d="M50 23A77 77 0 0 0 50 177" stroke-dasharray="6 5" stroke-dashoffset="30"/><path class="a" d="M50 16A84 84 0 0 1 50 184"/><path class="b" d="M50 16A84 84 0 0 0 50 184" stroke-dasharray="9 6" stroke-dashoffset="33"/><path class="a" d="M50 9A91 91 0 0 1 50 191"/><path class="b" d="M50 9A91 91 0 0 0 50 191" stroke-dasharray="3 3" stroke-dashoffset="36"/><path class="a" d="M50 2A98 98 0 0 1 50 198"/><path class="b" d="M50 2A98 98 0 0 0 50 198" stroke-dasharray="6 4" stroke-dashoffset="39"/><rect class="t" stroke="none" x="0" y="74" width="100" height="30"/></g><path class="t" d="M37 50Q42 47 46 52Q41 53 37 50ZM63 50Q58 47 54 52Q59 53 63 50Z"/></svg>

Before

Width:  |  Height:  |  Size: 66 KiB

After

Width:  |  Height:  |  Size: 2.6 KiB

+1 -1
View File
@@ -1 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 128 128" role="img" aria-label="Guará"><defs><linearGradient id="bg" x1="0" y1="0" x2="1" y2="1"><stop offset="0" stop-color="#0f3d44"/><stop offset="1" stop-color="#062a31"/></linearGradient><clipPath id="ic"><rect width="128" height="128" rx="29"/></clipPath></defs><rect width="128" height="128" rx="29" fill="url(#bg)"/><g clip-path="url(#ic)"><g transform="translate(-48 20) scale(1.06)"><polygon points="146.58,7.00 144.87,10.85 147.43,12.13" fill="#38d3c1" stroke="#38d3c1" stroke-width="0.25" stroke-linejoin="round"/><polygon points="131.94,67.89 135.88,72.47 135.24,69.04" fill="#0a424e" stroke="#0a424e" stroke-width="0.25" stroke-linejoin="round"/><polygon points="112.13,68.19 116.20,66.47 107.81,62.69" fill="#23b8aa" stroke="#23b8aa" stroke-width="0.25" stroke-linejoin="round"/><polygon points="143.15,8.71 144.87,10.85 146.58,7.00" fill="#38d3c0" stroke="#38d3c0" stroke-width="0.25" stroke-linejoin="round"/><polygon points="101.86,14.48 105.07,14.27 104.21,11.27" fill="#2dc5b5" stroke="#2dc5b5" stroke-width="0.25" stroke-linejoin="round"/><polygon points="108.92,6.14 112.34,8.28 111.92,4.43" fill="#2dc5b5" stroke="#2dc5b5" stroke-width="0.25" stroke-linejoin="round"/><polygon points="37.51,61.88 38.06,58.55 35.26,59.42" fill="#16a69b" stroke="#16a69b" stroke-width="0.25" stroke-linejoin="round" fill-opacity="0.44" stroke-opacity="0.44"/><polygon points="51.64,65.75 54.46,64.96 52.55,62.38" fill="#16a79b" stroke="#16a79b" stroke-width="0.25" stroke-linejoin="round" fill-opacity="0.66" stroke-opacity="0.66"/><polygon points="46.20,62.56 49.71,66.06 50.53,62.99" fill="#1baea1" stroke="#1baea1" stroke-width="0.25" stroke-linejoin="round" fill-opacity="0.58" stroke-opacity="0.58"/><polygon points="48.26,63.58 45.03,60.36 44.41,64.13" fill="#12a298" stroke="#12a298" stroke-width="0.25" stroke-linejoin="round" fill-opacity="0.52" stroke-opacity="0.52"/><polygon points="61.85,68.19 62.92,72.99 65.81,67.07" fill="#13a398" stroke="#13a398" stroke-width="0.25" stroke-linejoin="round"/><polygon points="62.92,72.99 61.85,68.19 55.42,69.11" fill="#19ab9f" stroke="#19ab9f" stroke-width="0.25" stroke-linejoin="round"/><polygon points="38.33,89.93 36.63,88.22 36.63,89.93" fill="#0f9e94" stroke="#0f9e94" stroke-width="0.25" stroke-linejoin="round" fill-opacity="0.39" stroke-opacity="0.39"/><polygon points="98.42,72.35 97.37,66.47 91.80,72.47" fill="#a9f2e5" stroke="#a9f2e5" stroke-width="0.25" stroke-linejoin="round"/><polygon points="92.66,77.17 98.42,72.35 91.80,72.47" fill="#a6f2e5" stroke="#a6f2e5" stroke-width="0.25" stroke-linejoin="round"/><polygon points="98.42,72.35 92.66,77.17 100.36,80.17" fill="#aff3e7" stroke="#aff3e7" stroke-width="0.25" stroke-linejoin="round"/><polygon points="85.59,79.64 92.66,77.17 91.80,72.47" fill="#17a89c" stroke="#17a89c" stroke-width="0.25" stroke-linejoin="round"/><polygon points="92.66,77.17 99.65,82.45 100.36,80.17" fill="#1fb2a5" stroke="#1fb2a5" stroke-width="0.25" stroke-linejoin="round"/><polygon points="99.65,82.45 92.66,77.17 96.80,84.95" fill="#1db0a3" stroke="#1db0a3" stroke-width="0.25" stroke-linejoin="round"/><polygon points="133.31,53.64 131.39,55.35 133.74,59.63" fill="#109087" stroke="#109087" stroke-width="0.25" stroke-linejoin="round"/><polygon points="121.41,64.97 128.18,59.63 123.90,58.77" fill="#093f4a" stroke="#093f4a" stroke-width="0.25" stroke-linejoin="round"/><polygon points="108.07,68.61 112.13,68.19 107.81,62.69" fill="#1aaca0" stroke="#1aaca0" stroke-width="0.25" stroke-linejoin="round"/><polygon points="127.98,73.39 135.88,72.47 131.94,67.89" fill="#093c48" stroke="#093c48" stroke-width="0.25" stroke-linejoin="round"/><polygon points="127.98,73.39 124.18,72.59 121.76,80.81" fill="#093e49" stroke="#093e49" stroke-width="0.25" stroke-linejoin="round"/><polygon points="124.18,72.59 118.91,75.14 121.76,80.81" fill="#093f4b" stroke="#093f4b" stroke-width="0.25" stroke-linejoin="round"/><polygon points="143.15,8.71 140.16,10.63 144.87,10.85" fill="#33cdbb" stroke="#33cdbb" stroke-width="0.25" stroke-linejoin="round"/><polygon points="144.01,27.53 139.52,28.60 142.08,31.60" fill="#2cc3b3" stroke="#2cc3b3" stroke-width="0.25" stroke-linejoin="round"/><polygon points="128.18,59.63 134.60,61.77 133.74,59.63" fill="#0a414d" stroke="#0a414d" stroke-width="0.25" stroke-linejoin="round"/><polygon points="134.60,61.77 128.18,59.63 131.94,67.89" fill="#0a424e" stroke="#0a424e" stroke-width="0.25" stroke-linejoin="round"/><polygon points="109.35,9.56 108.92,6.14 106.57,8.71" fill="#30c9b8" stroke="#30c9b8" stroke-width="0.25" stroke-linejoin="round"/><polygon points="109.35,9.56 112.34,8.28 108.92,6.14" fill="#31cab9" stroke="#31cab9" stroke-width="0.25" stroke-linejoin="round"/><polygon points="104.21,11.27 109.35,9.56 106.57,8.71" fill="#31cab9" stroke="#31cab9" stroke-width="0.25" stroke-linejoin="round"/><polygon points="105.07,14.27 109.35,9.56 104.21,11.27" fill="#2fc7b6" stroke="#2fc7b6" stroke-width="0.25Line truncated
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" role="img" aria-label="Guará"><style>.a{stroke:#0f766e}.b{stroke:#14b8a6}.t{fill:#1d1d1f}@media (prefers-color-scheme:dark){.a{stroke:#2dd4bf}.b{stroke:#5eead4}.t{fill:#f5f5f7}}</style><defs><clipPath id="g-head"><path d="M50 95 C46 88 43 80 40 74 C33 70 25 64 22 56 L14 6 L36 30 C40 28 45 27 50 27 C55 27 60 28 64 30 L86 6 L78 56 C75 64 67 70 60 74 C57 80 54 88 50 95 Z"/></clipPath></defs><g clip-path="url(#g-head)" fill="none" stroke-width="4.2"><path class="a" d="M50 93A7 7 0 0 1 50 107"/><path class="b" d="M50 93A7 7 0 0 0 50 107" stroke-dasharray="3 3" stroke-dashoffset="0"/><path class="a" d="M50 86A14 14 0 0 1 50 114"/><path class="b" d="M50 86A14 14 0 0 0 50 114" stroke-dasharray="6 4" stroke-dashoffset="3"/><path class="a" d="M50 79A21 21 0 0 1 50 121"/><path class="b" d="M50 79A21 21 0 0 0 50 121" stroke-dasharray="9 5" stroke-dashoffset="6"/><path class="a" d="M50 72A28 28 0 0 1 50 128"/><path class="b" d="M50 72A28 28 0 0 0 50 128" stroke-dasharray="3 6" stroke-dashoffset="9"/><path class="a" d="M50 65A35 35 0 0 1 50 135"/><path class="b" d="M50 65A35 35 0 0 0 50 135" stroke-dasharray="6 3" stroke-dashoffset="12"/><path class="a" d="M50 58A42 42 0 0 1 50 142"/><path class="b" d="M50 58A42 42 0 0 0 50 142" stroke-dasharray="9 4" stroke-dashoffset="15"/><path class="a" d="M50 51A49 49 0 0 1 50 149"/><path class="b" d="M50 51A49 49 0 0 0 50 149" stroke-dasharray="3 5" stroke-dashoffset="18"/><path class="a" d="M50 44A56 56 0 0 1 50 156"/><path class="b" d="M50 44A56 56 0 0 0 50 156" stroke-dasharray="6 6" stroke-dashoffset="21"/><path class="a" d="M50 37A63 63 0 0 1 50 163"/><path class="b" d="M50 37A63 63 0 0 0 50 163" stroke-dasharray="9 3" stroke-dashoffset="24"/><path class="a" d="M50 30A70 70 0 0 1 50 170"/><path class="b" d="M50 30A70 70 0 0 0 50 170" stroke-dasharray="3 4" stroke-dashoffset="27"/><path class="a" d="M50 23A77 77 0 0 1 50 177"/><path class="b" d="M50 23A77 77 0 0 0 50 177" stroke-dasharray="6 5" stroke-dashoffset="30"/><path class="a" d="M50 16A84 84 0 0 1 50 184"/><path class="b" d="M50 16A84 84 0 0 0 50 184" stroke-dasharray="9 6" stroke-dashoffset="33"/><path class="a" d="M50 9A91 91 0 0 1 50 191"/><path class="b" d="M50 9A91 91 0 0 0 50 191" stroke-dasharray="3 3" stroke-dashoffset="36"/><path class="a" d="M50 2A98 98 0 0 1 50 198"/><path class="b" d="M50 2A98 98 0 0 0 50 198" stroke-dasharray="6 4" stroke-dashoffset="39"/><rect class="t" stroke="none" x="0" y="74" width="100" height="30"/></g><path class="t" d="M37 50Q42 47 46 52Q41 53 37 50ZM63 50Q58 47 54 52Q59 53 63 50Z"/></svg>

Before

Width:  |  Height:  |  Size: 66 KiB

After

Width:  |  Height:  |  Size: 2.6 KiB

+43
View File
@@ -1,5 +1,48 @@
// Dicionário português -> inglês da interface. {n} marca um valor variável.
export const EN = {
// saúde do disco (SMART)
'Saúde do disco': 'Disk health',
'O SMART não pôde ser lido. Instale o pacote smartmontools (comando smartctl) e rode como administrador para ver a saúde do disco.': 'SMART could not be read. Install the smartmontools package (smartctl command) and run as administrator to see the disk health.',
'Setores realocados': 'Reallocated sectors',
'Setores pendentes de realocação': 'Pending sectors',
'Setores incorrigíveis offline': 'Offline uncorrectable sectors',
'Erros incorrigíveis reportados': 'Reported uncorrectable errors',
'Erros de CRC na interface (cabo ou porta)': 'Interface CRC errors (cable or port)',
'Erros registrados no log do disco': 'Errors in the disk log',
'Aviso crítico NVMe': 'NVMe critical warning',
'Erros de mídia': 'Media errors',
'Reserva de blocos abaixo do limite': 'Spare blocks below threshold',
'Erros de leitura/gravação vistos pelo sistema': 'Read/write errors seen by the system',
'O sistema já registrou erros de E/S neste disco.': 'The system has already logged I/O errors on this disk.',
'Estado': 'Status',
'Bom': 'Good',
'Atenção': 'Caution',
'Ruim': 'Bad',
'Temperatura': 'Temperature',
'Horas ligado': 'Power on hours',
'Vezes ligado': 'Power on count',
'Total lido': 'Host reads',
'Total gravado': 'Host writes',
'Atributos SMART ({n})': 'SMART attributes ({n})',
'Atributo': 'Attribute',
'Atual': 'Current',
'Pior': 'Worst',
'Limite': 'Threshold',
'Bruto': 'Raw',
'Modelo': 'Model',
'Nº de série': 'Serial number',
'Família': 'Family',
'Modo de transferência': 'Transfer mode',
'Capacidade': 'Capacity',
'Rotação': 'Rotation rate',
'Formato': 'Form factor',
'Recursos': 'Features',
'O SMART é do disco inteiro: os dados abaixo são de': 'SMART belongs to the whole disk: the data below is for',
', que contém': ', which contains',
'Imagem de disco: não há SMART para avaliar.': 'Disk image: there is no SMART to check.',
'Nenhum sinal de defeito encontrado pelo SMART.': 'SMART found no signs of failure.',
'Este disco mostra sinais sérios de defeito.': 'This disk shows serious signs of failure.',
'Este disco mostra sinais de desgaste ou erros.': 'This disk shows signs of wear or errors.',
// barra lateral e estrutura
'Recuperação de arquivos': 'File recovery',
'Dispositivos': 'Devices',
+2 -2
View File
@@ -14,10 +14,10 @@
<button class="icon-btn" id="menuBtn" aria-label="Abrir menu" aria-expanded="false">
<svg viewBox="0 0 24 24" width="22" height="22"><path d="M4 7h16M4 12h16M4 17h16" stroke="currentColor" stroke-width="2" stroke-linecap="round" fill="none"/></svg>
</button>
<img src="guara.svg" alt="" width="24" height="24"><strong>Guará</strong>
<svg class="logo" width="24" height="24" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><defs><clipPath id="g-head-top"><path d="M50 95 C46 88 43 80 40 74 C33 70 25 64 22 56 L14 6 L36 30 C40 28 45 27 50 27 C55 27 60 28 64 30 L86 6 L78 56 C75 64 67 70 60 74 C57 80 54 88 50 95 Z"/></clipPath></defs><g clip-path="url(#g-head-top)" fill="none" stroke-width="4.2"><path class="a" d="M50 93A7 7 0 0 1 50 107"/><path class="b" d="M50 93A7 7 0 0 0 50 107" stroke-dasharray="3 3" stroke-dashoffset="0"/><path class="a" d="M50 86A14 14 0 0 1 50 114"/><path class="b" d="M50 86A14 14 0 0 0 50 114" stroke-dasharray="6 4" stroke-dashoffset="3"/><path class="a" d="M50 79A21 21 0 0 1 50 121"/><path class="b" d="M50 79A21 21 0 0 0 50 121" stroke-dasharray="9 5" stroke-dashoffset="6"/><path class="a" d="M50 72A28 28 0 0 1 50 128"/><path class="b" d="M50 72A28 28 0 0 0 50 128" stroke-dasharray="3 6" stroke-dashoffset="9"/><path class="a" d="M50 65A35 35 0 0 1 50 135"/><path class="b" d="M50 65A35 35 0 0 0 50 135" stroke-dasharray="6 3" stroke-dashoffset="12"/><path class="a" d="M50 58A42 42 0 0 1 50 142"/><path class="b" d="M50 58A42 42 0 0 0 50 142" stroke-dasharray="9 4" stroke-dashoffset="15"/><path class="a" d="M50 51A49 49 0 0 1 50 149"/><path class="b" d="M50 51A49 49 0 0 0 50 149" stroke-dasharray="3 5" stroke-dashoffset="18"/><path class="a" d="M50 44A56 56 0 0 1 50 156"/><path class="b" d="M50 44A56 56 0 0 0 50 156" stroke-dasharray="6 6" stroke-dashoffset="21"/><path class="a" d="M50 37A63 63 0 0 1 50 163"/><path class="b" d="M50 37A63 63 0 0 0 50 163" stroke-dasharray="9 3" stroke-dashoffset="24"/><path class="a" d="M50 30A70 70 0 0 1 50 170"/><path class="b" d="M50 30A70 70 0 0 0 50 170" stroke-dasharray="3 4" stroke-dashoffset="27"/><path class="a" d="M50 23A77 77 0 0 1 50 177"/><path class="b" d="M50 23A77 77 0 0 0 50 177" stroke-dasharray="6 5" stroke-dashoffset="30"/><path class="a" d="M50 16A84 84 0 0 1 50 184"/><path class="b" d="M50 16A84 84 0 0 0 50 184" stroke-dasharray="9 6" stroke-dashoffset="33"/><path class="a" d="M50 9A91 91 0 0 1 50 191"/><path class="b" d="M50 9A91 91 0 0 0 50 191" stroke-dasharray="3 3" stroke-dashoffset="36"/><path class="a" d="M50 2A98 98 0 0 1 50 198"/><path class="b" d="M50 2A98 98 0 0 0 50 198" stroke-dasharray="6 4" stroke-dashoffset="39"/><rect class="t" stroke="none" x="0" y="74" width="100" height="30"/></g><path class="t" d="M37 50Q42 47 46 52Q41 53 37 50ZM63 50Q58 47 54 52Q59 53 63 50Z"/></svg><strong>Guará</strong>
</header>
<aside class="sidebar" id="sidebar" aria-label="Dispositivos e sessões">
<div class="brand"><img src="guara.svg" alt="" width="30" height="30"><div><strong>Guará</strong><small>Recuperação de arquivos</small></div></div>
<div class="brand"><svg class="logo" width="30" height="30" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><defs><clipPath id="g-head-side"><path d="M50 95 C46 88 43 80 40 74 C33 70 25 64 22 56 L14 6 L36 30 C40 28 45 27 50 27 C55 27 60 28 64 30 L86 6 L78 56 C75 64 67 70 60 74 C57 80 54 88 50 95 Z"/></clipPath></defs><g clip-path="url(#g-head-side)" fill="none" stroke-width="4.2"><path class="a" d="M50 93A7 7 0 0 1 50 107"/><path class="b" d="M50 93A7 7 0 0 0 50 107" stroke-dasharray="3 3" stroke-dashoffset="0"/><path class="a" d="M50 86A14 14 0 0 1 50 114"/><path class="b" d="M50 86A14 14 0 0 0 50 114" stroke-dasharray="6 4" stroke-dashoffset="3"/><path class="a" d="M50 79A21 21 0 0 1 50 121"/><path class="b" d="M50 79A21 21 0 0 0 50 121" stroke-dasharray="9 5" stroke-dashoffset="6"/><path class="a" d="M50 72A28 28 0 0 1 50 128"/><path class="b" d="M50 72A28 28 0 0 0 50 128" stroke-dasharray="3 6" stroke-dashoffset="9"/><path class="a" d="M50 65A35 35 0 0 1 50 135"/><path class="b" d="M50 65A35 35 0 0 0 50 135" stroke-dasharray="6 3" stroke-dashoffset="12"/><path class="a" d="M50 58A42 42 0 0 1 50 142"/><path class="b" d="M50 58A42 42 0 0 0 50 142" stroke-dasharray="9 4" stroke-dashoffset="15"/><path class="a" d="M50 51A49 49 0 0 1 50 149"/><path class="b" d="M50 51A49 49 0 0 0 50 149" stroke-dasharray="3 5" stroke-dashoffset="18"/><path class="a" d="M50 44A56 56 0 0 1 50 156"/><path class="b" d="M50 44A56 56 0 0 0 50 156" stroke-dasharray="6 6" stroke-dashoffset="21"/><path class="a" d="M50 37A63 63 0 0 1 50 163"/><path class="b" d="M50 37A63 63 0 0 0 50 163" stroke-dasharray="9 3" stroke-dashoffset="24"/><path class="a" d="M50 30A70 70 0 0 1 50 170"/><path class="b" d="M50 30A70 70 0 0 0 50 170" stroke-dasharray="3 4" stroke-dashoffset="27"/><path class="a" d="M50 23A77 77 0 0 1 50 177"/><path class="b" d="M50 23A77 77 0 0 0 50 177" stroke-dasharray="6 5" stroke-dashoffset="30"/><path class="a" d="M50 16A84 84 0 0 1 50 184"/><path class="b" d="M50 16A84 84 0 0 0 50 184" stroke-dasharray="9 6" stroke-dashoffset="33"/><path class="a" d="M50 9A91 91 0 0 1 50 191"/><path class="b" d="M50 9A91 91 0 0 0 50 191" stroke-dasharray="3 3" stroke-dashoffset="36"/><path class="a" d="M50 2A98 98 0 0 1 50 198"/><path class="b" d="M50 2A98 98 0 0 0 50 198" stroke-dasharray="6 4" stroke-dashoffset="39"/><rect class="t" stroke="none" x="0" y="74" width="100" height="30"/></g><path class="t" d="M37 50Q42 47 46 52Q41 53 37 50ZM63 50Q58 47 54 52Q59 53 63 50Z"/></svg><div><strong>Guará</strong><small>Recuperação de arquivos</small></div></div>
<nav>
<div class="side-title">Dispositivos <button class="icon-btn small" id="refreshBtn" title="Atualizar lista" aria-label="Atualizar lista"><svg viewBox="0 0 24 24" width="16" height="16"><path d="M20 12a8 8 0 1 1-2.5-5.8M20 4v5h-5" stroke="currentColor" stroke-width="2" fill="none" stroke-linecap="round" stroke-linejoin="round"/></svg></button></div>
<ul id="deviceList" class="list"></ul>
+111
View File
@@ -32,6 +32,13 @@ enum Cmd {
#[arg(long)]
json: bool,
},
/// Saúde do disco (SMART): estado, temperatura, uso e tabela de atributos
Health {
/// Dispositivo ou partição (o SMART lido é o do disco que a contém)
path: String,
#[arg(long)]
json: bool,
},
/// Procura arquivos apagados/perdidos (metadados + assinatura)
Scan(ScanArgs),
/// Continua uma varredura pausada (Ctrl+C) a partir do arquivo de sessão
@@ -206,6 +213,15 @@ fn run(cli: Cli) -> Result<(), String> {
}
Ok(())
}
Cmd::Health { path, json } => {
let v = eng.rpc("health", json!({ "path": path })).map_err(s)?;
if json {
println!("{}", serde_json::to_string_pretty(&v).unwrap());
} else {
print_health(&v);
}
Ok(())
}
Cmd::Scan(a) => {
let opts = ScanOptions {
mode: if a.quick {
@@ -702,3 +718,98 @@ fn paint(code: &str, s: &str) -> String {
fn s<E: std::fmt::Display>(e: E) -> String {
e.to_string()
}
fn print_health(v: &Value) {
let st = v["status"].as_str().unwrap_or("unknown");
if !v["available"].as_bool().unwrap_or(false) {
println!("{}", v["summary"].as_str().unwrap_or(""));
return;
}
let word = match st {
"ok" => paint("32", "Bom"),
"warning" => paint("33", "Atenção"),
"failing" => paint("31", "Ruim"),
_ => "?".into(),
};
let pct = v["health_pct"]
.as_u64()
.map(|p| format!(" ({p}%)"))
.unwrap_or_default();
println!("Disco: {}", v["disk"].as_str().unwrap_or(""));
if let Some(p) = v["partition"].as_str() {
println!(" (o SMART é do disco inteiro que contém {p})");
}
println!(
"Estado: {word}{pct} {}",
v["summary"].as_str().unwrap_or("")
);
let num = |k: &str| v[k].as_i64();
let bytes = |k: &str| v[k].as_u64().map(human);
let mut m = Vec::new();
if let Some(t) = num("temperature_c") {
m.push(format!("Temperatura: {t} °C"));
}
if let Some(h) = num("power_on_hours") {
m.push(format!("Horas ligado: {h}"));
}
if let Some(c) = num("power_cycles") {
m.push(format!("Vezes ligado: {c}"));
}
if let Some(r) = bytes("host_reads") {
m.push(format!("Total lido: {r}"));
}
if let Some(w) = bytes("host_writes") {
m.push(format!("Total gravado: {w}"));
}
if !m.is_empty() {
println!("{}", m.join(" · "));
}
if st != "ok" {
for kv in v["details"].as_array().into_iter().flatten() {
println!(
" ! {}: {}",
kv[0].as_str().unwrap_or(""),
kv[1].as_str().unwrap_or("")
);
}
}
println!();
for kv in v["info"].as_array().into_iter().flatten() {
println!(
" {:<24}{}",
kv[0].as_str().unwrap_or(""),
kv[1].as_str().unwrap_or("")
);
}
let attrs = v["attributes"].as_array().cloned().unwrap_or_default();
if !attrs.is_empty() {
let o = |x: &Value| {
x.as_i64()
.map(|n| n.to_string())
.unwrap_or_else(|| "-".into())
};
println!(
"\n ID {:<34}{:>6}{:>6}{:>7} Bruto",
"Atributo", "Atual", "Pior", "Limite"
);
for a in attrs {
let dot = match a["status"].as_str() {
Some("failing") => paint("31", "●"),
Some("warning") => paint("33", "●"),
_ => paint("32", "●"),
};
println!(
" {dot} {:<3} {:<34}{:>6}{:>6}{:>7} {}",
a["id"].as_str().unwrap_or(""),
a["name"].as_str().unwrap_or(""),
o(&a["value"]),
o(&a["worst"]),
o(&a["thresh"]),
a["raw"].as_str().unwrap_or("")
);
}
}
for adv in v["advice"].as_array().into_iter().flatten() {
println!("\n{}", adv.as_str().unwrap_or(""));
}
}
+290 -2
View File
@@ -15,6 +15,37 @@ pub struct Health {
pub summary: String,
pub details: Vec<(String, String)>,
pub advice: Vec<String>,
/// Ficha do dispositivo, no estilo do CrystalDiskInfo (modelo, firmware, interface...).
pub info: Vec<(String, String)>,
/// Saúde estimada em % (SSD: vida útil restante). `None` em HD, que não informa isso.
pub health_pct: Option<u8>,
pub temperature_c: Option<i64>,
pub power_on_hours: Option<i64>,
pub power_cycles: Option<i64>,
/// Total lido e gravado pelo computador, em bytes, quando o disco informa.
pub host_reads: Option<u64>,
pub host_writes: Option<u64>,
/// Tabela completa de atributos SMART.
pub attributes: Vec<Attr>,
/// Caminho avaliado de fato (o disco inteiro, quando `path` é uma partição).
pub disk: String,
/// Partição pedida, quando a avaliação foi feita no disco que a contém.
pub partition: Option<String>,
}
/// Uma linha da tabela de atributos SMART.
#[derive(Debug, Clone, Serialize, Default)]
pub struct Attr {
/// Identificador em hexadecimal, como o CrystalDiskInfo mostra ("05", "C5").
pub id: String,
pub name: String,
/// Valores normalizados (ATA): atual, pior já visto e limite de falha.
pub value: Option<i64>,
pub worst: Option<i64>,
pub thresh: Option<i64>,
pub raw: String,
/// "ok", "warning" ou "failing".
pub status: String,
}
impl Health {
@@ -44,14 +75,47 @@ pub fn check(path: &str) -> Health {
if !is_dev {
return Health::unknown("Imagem de disco: não há SMART para avaliar.");
}
let mut h = match run_smartctl(path) {
let disk = parent_disk(path);
let mut h = match run_smartctl(&disk) {
Some(v) => parse_smartctl(&v),
None => Health::unknown("O SMART não pôde ser lido. Instale o pacote smartmontools (comando smartctl) e rode como administrador para ver a saúde do disco."),
};
kernel_errors(path, &mut h);
if disk != path {
h.partition = Some(path.to_string());
}
h.disk = disk;
h
}
/// O SMART é do disco, não da partição: `/dev/sda1` vira `/dev/sda`,
/// `/dev/nvme0n1p2` vira `/dev/nvme0n1` e `/dev/disk2s1` vira `/dev/disk2`.
pub fn parent_disk(path: &str) -> String {
#[cfg(target_os = "linux")]
{
let name = path.trim_start_matches("/dev/");
let sys = format!("/sys/class/block/{name}");
if std::path::Path::new(&format!("{sys}/partition")).exists() {
if let Ok(real) = std::fs::canonicalize(&sys) {
if let Some(p) = real.parent().and_then(|p| p.file_name()) {
return format!("/dev/{}", p.to_string_lossy());
}
}
}
}
#[cfg(target_os = "macos")]
{
for pre in ["/dev/rdisk", "/dev/disk"] {
if let Some(rest) = path.strip_prefix(pre) {
if let Some(i) = rest.find('s') {
return format!("{pre}{}", &rest[..i]);
}
}
}
}
path.to_string()
}
fn smartctl_name(path: &str) -> String {
// Windows: \\.\PhysicalDriveN -> /dev/sdX (convenção do smartctl)
if let Some(n) = path
@@ -70,7 +134,7 @@ fn smartctl_name(path: &str) -> String {
fn run_smartctl(path: &str) -> Option<Value> {
let dev = smartctl_name(path);
let out = Command::new("smartctl")
.args(["--json=o", "-H", "-A", "-i", "-l", "error", &dev])
.args(["--json=o", "-a", &dev])
.stdin(Stdio::null())
.stderr(Stdio::null())
.output()
@@ -111,6 +175,8 @@ pub fn parse_smartctl(v: &Value) -> Health {
bad = bad.max(sev);
h.details.push((k.to_string(), val));
};
fill_info(v, &mut h);
fill_attributes(v, &mut h);
if let Some(m) = v["model_name"].as_str() {
h.details.push(("Modelo".into(), m.to_string()));
}
@@ -225,6 +291,9 @@ pub fn parse_smartctl(v: &Value) -> Health {
}
}
}
if h.attributes.iter().any(|a| a.status == "failing") {
bad = 2;
}
match bad {
2 => {
h.status = "failing".into();
@@ -241,6 +310,225 @@ pub fn parse_smartctl(v: &Value) -> Health {
h
}
fn s(v: &Value, p: &str) -> Option<String> {
v.pointer(p)
.and_then(|x| x.as_str())
.map(|x| x.trim().to_string())
.filter(|x| !x.is_empty())
}
fn n(v: &Value, p: &str) -> Option<i64> {
v.pointer(p).and_then(|x| x.as_i64())
}
/// Ficha do dispositivo e métricas gerais (temperatura, horas, total lido/gravado, saúde %).
fn fill_info(v: &Value, h: &mut Health) {
let mut put = |k: &str, val: Option<String>| {
if let Some(val) = val {
h.info.push((k.to_string(), val));
}
};
put(
"Modelo",
s(v, "/model_name").or_else(|| {
let a = s(v, "/scsi_vendor")?;
Some(format!("{a} {}", s(v, "/scsi_product").unwrap_or_default()))
}),
);
put("Firmware", s(v, "/firmware_version"));
put("Nº de série", s(v, "/serial_number"));
put("Família", s(v, "/model_family"));
let proto = s(v, "/device/protocol");
let iface = s(v, "/sata_version/string").or_else(|| {
let sp = v
.pointer("/nvme_pci_vendor")
.map(|_| "NVM Express".to_string());
sp.or_else(|| proto.clone())
});
put("Interface", iface);
let speed = |p: &str| s(v, &format!("/interface_speed/{p}/string"));
put(
"Modo de transferência",
match (speed("current"), speed("max")) {
(Some(c), Some(m)) if c != m => Some(format!("{c} (máx. {m})")),
(Some(c), _) => Some(c),
(None, Some(m)) => Some(m),
_ => None,
},
);
put(
"Capacidade",
n(v, "/user_capacity/bytes")
.or_else(|| n(v, "/nvme_total_capacity"))
.map(|b| decimal_size(b as u64)),
);
put(
"Rotação",
n(v, "/rotation_rate").map(|r| {
if r == 0 {
"SSD (sem rotação)".into()
} else {
format!("{r} RPM")
}
}),
);
put("Formato", s(v, "/form_factor/name"));
let mut feats = Vec::new();
if v.pointer("/smart_support/enabled") == Some(&Value::Bool(true))
|| v.get("nvme_smart_health_information_log").is_some()
{
feats.push("S.M.A.R.T.");
}
if v.pointer("/trim/supported") == Some(&Value::Bool(true)) {
feats.push("TRIM");
}
if v.pointer("/write_cache/enabled") == Some(&Value::Bool(true)) {
feats.push("Cache de gravação");
}
if v.get("ata_security").and_then(|x| x.get("enabled")) == Some(&Value::Bool(true)) {
feats.push("Segurança ATA");
}
if !feats.is_empty() {
put("Recursos", Some(feats.join(", ")));
}
h.temperature_c = n(v, "/temperature/current");
h.power_on_hours = n(v, "/power_on_time/hours");
h.power_cycles = n(v, "/power_cycle_count");
if let Some(l) = v.get("nvme_smart_health_information_log") {
// a unidade NVMe vale 1000 setores de 512 bytes
h.host_reads = l["data_units_read"].as_u64().map(|u| u * 512_000);
h.host_writes = l["data_units_written"].as_u64().map(|u| u * 512_000);
h.health_pct = l["percentage_used"]
.as_i64()
.map(|u| (100 - u.clamp(0, 100)) as u8);
h.power_cycles = h.power_cycles.or(l["power_cycles"].as_i64());
} else {
let lba = n(v, "/logical_block_size").unwrap_or(512) as u64;
h.host_reads = attr(v, 242).map(|x| x as u64 * lba);
h.host_writes = attr(v, 241).map(|x| x as u64 * lba);
// SSD SATA: vida útil restante no valor normalizado de um destes atributos
// (231 SSD Life Left, 233 Media Wearout, 177 Wear Leveling, 202 Percent Lifetime Remain)
h.health_pct = [231u64, 233, 177, 202, 169]
.iter()
.find_map(|&id| attr_field(v, id, "value"))
.filter(|_| n(v, "/rotation_rate") == Some(0))
.map(|x| x.clamp(0, 100) as u8);
}
}
/// Capacidade como o fabricante anuncia (base 1000): "500,1 GB".
fn decimal_size(b: u64) -> String {
let units = ["B", "kB", "MB", "GB", "TB", "PB"];
let mut x = b as f64;
let mut i = 0;
while x >= 1000.0 && i < units.len() - 1 {
x /= 1000.0;
i += 1;
}
format!("{x:.1} {}", units[i]).replace('.', ",")
}
fn attr_field(v: &Value, id: u64, f: &str) -> Option<i64> {
v.pointer("/ata_smart_attributes/table")?
.as_array()?
.iter()
.find(|a| a["id"] == id)?
.get(f)?
.as_i64()
}
/// Atributos cujo valor bruto acima de zero já é motivo de atenção.
const RAW_WARN: [u64; 5] = [5, 196, 197, 198, 187];
fn fill_attributes(v: &Value, h: &mut Health) {
if let Some(t) = v
.pointer("/ata_smart_attributes/table")
.and_then(|t| t.as_array())
{
for a in t {
let id = a["id"].as_u64().unwrap_or(0);
let value = a["value"].as_i64();
let thresh = a["thresh"].as_i64();
let raw_n = a
.pointer("/raw/value")
.and_then(|x| x.as_i64())
.unwrap_or(0);
let failing = a
.pointer("/when_failed")
.and_then(|x| x.as_str())
.is_some_and(|w| w == "now")
|| matches!((value, thresh), (Some(v), Some(t)) if t > 0 && v <= t);
let status = if failing {
"failing"
} else if RAW_WARN.contains(&id) && raw_n > 0 {
"warning"
} else {
"ok"
};
h.attributes.push(Attr {
id: format!("{id:02X}"),
name: a["name"]
.as_str()
.unwrap_or("Unknown_Attribute")
.replace('_', " "),
value,
worst: a["worst"].as_i64(),
thresh,
raw: a
.pointer("/raw/string")
.and_then(|x| x.as_str())
.map(str::to_string)
.unwrap_or_else(|| raw_n.to_string()),
status: status.into(),
});
}
}
if let Some(l) = v.get("nvme_smart_health_information_log") {
// mesma ordem e nomes que o CrystalDiskInfo usa para NVMe
let rows: [(u8, &str, &str); 15] = [
(1, "Critical Warning", "critical_warning"),
(2, "Composite Temperature", "temperature"),
(3, "Available Spare", "available_spare"),
(4, "Available Spare Threshold", "available_spare_threshold"),
(5, "Percentage Used", "percentage_used"),
(6, "Data Units Read", "data_units_read"),
(7, "Data Units Written", "data_units_written"),
(8, "Host Read Commands", "host_reads"),
(9, "Host Write Commands", "host_writes"),
(10, "Controller Busy Time", "controller_busy_time"),
(11, "Power Cycles", "power_cycles"),
(12, "Power On Hours", "power_on_hours"),
(13, "Unsafe Shutdowns", "unsafe_shutdowns"),
(14, "Media and Data Integrity Errors", "media_errors"),
(
15,
"Number of Error Information Log Entries",
"num_err_log_entries",
),
];
let spare_low = matches!((l["available_spare"].as_i64(), l["available_spare_threshold"].as_i64()), (Some(s), Some(t)) if s < t);
for (id, name, key) in rows {
let Some(x) = l.get(key).and_then(|x| x.as_i64()) else {
continue;
};
let status = match key {
"critical_warning" | "media_errors" if x > 0 => "failing",
"available_spare" if spare_low => "failing",
"percentage_used" if x >= 100 => "failing",
"percentage_used" if x >= 90 => "warning",
_ => "ok",
};
h.attributes.push(Attr {
id: format!("{id:02X}"),
name: name.into(),
raw: x.to_string(),
status: status.into(),
..Default::default()
});
}
}
}
/// Contadores de erro de E/S do kernel (Linux): reforçam o aviso do SMART.
fn kernel_errors(path: &str, h: &mut Health) {
#[cfg(target_os = "linux")]
+60
View File
@@ -51,6 +51,66 @@ fn smart_saudavel_nvme_desgastado_e_nvme_critico() {
assert_eq!(health::parse_smartctl(&media).status, "failing");
}
#[test]
fn smart_ssd_sata_traz_ficha_metricas_e_tabela() {
let v = json!({
"device": {"protocol": "ATA"},
"model_name": "Samsung SSD 860 EVO 500GB", "firmware_version": "RVT04B6Q",
"serial_number": "S3Z1NB0K", "sata_version": {"string": "SATA 3.2"},
"interface_speed": {"max": {"string": "6.0 Gb/s"}, "current": {"string": "6.0 Gb/s"}},
"user_capacity": {"bytes": 500107862016u64}, "logical_block_size": 512, "rotation_rate": 0,
"smart_support": {"enabled": true}, "trim": {"supported": true},
"smart_status": {"passed": true}, "temperature": {"current": 31},
"power_on_time": {"hours": 12034}, "power_cycle_count": 811,
"ata_smart_attributes": {"table": [
{"id": 5, "name": "Reallocated_Sector_Ct", "value": 100, "worst": 100, "thresh": 10, "raw": {"value": 0, "string": "0"}},
{"id": 177, "name": "Wear_Leveling_Count", "value": 92, "worst": 92, "thresh": 0, "raw": {"value": 41, "string": "41"}},
{"id": 241, "name": "Total_LBAs_Written", "value": 99, "worst": 99, "thresh": 0, "raw": {"value": 2000000000u64, "string": "2000000000"}}
]}
});
let h = health::parse_smartctl(&v);
assert_eq!(h.status, "ok");
assert_eq!(h.health_pct, Some(92));
assert_eq!(h.temperature_c, Some(31));
assert_eq!(h.power_cycles, Some(811));
assert_eq!(h.host_writes, Some(2_000_000_000 * 512));
assert!(h
.info
.iter()
.any(|(k, v)| k == "Capacidade" && v == "500,1 GB"));
assert!(h
.info
.iter()
.any(|(k, v)| k == "Recursos" && v.contains("TRIM")));
assert_eq!(h.attributes.len(), 3);
assert_eq!(h.attributes[0].id, "05");
assert_eq!(h.attributes[0].name, "Reallocated Sector Ct");
assert_eq!(h.attributes[1].id, "B1");
}
#[test]
fn smart_atributo_abaixo_do_limite_reprova_e_nvme_vira_tabela() {
let v = json!({"smart_status": {"passed": true}, "ata_smart_attributes": {"table": [
{"id": 1, "name": "Raw_Read_Error_Rate", "value": 40, "worst": 40, "thresh": 51, "raw": {"value": 9}}
]}});
let h = health::parse_smartctl(&v);
assert_eq!(h.attributes[0].status, "failing");
assert_eq!(h.status, "failing");
let nv = json!({"smart_status": {"passed": true}, "nvme_smart_health_information_log": {
"critical_warning": 0, "temperature": 40, "available_spare": 100, "available_spare_threshold": 10,
"percentage_used": 3, "data_units_read": 1000, "data_units_written": 2000,
"power_cycles": 50, "power_on_hours": 900, "unsafe_shutdowns": 4, "media_errors": 0}});
let h = health::parse_smartctl(&nv);
assert_eq!(h.health_pct, Some(97));
assert_eq!(h.host_writes, Some(2000 * 512_000));
assert_eq!(h.power_cycles, Some(50));
assert!(h
.attributes
.iter()
.any(|a| a.id == "0D" && a.name == "Unsafe Shutdowns" && a.raw == "4"));
}
#[test]
fn imagem_de_disco_nao_tem_smart() {
let f = tempfile::NamedTempFile::new().unwrap();
+49 -123
View File
@@ -1,128 +1,54 @@
#!/usr/bin/env python3
"""Gera a logo do Guará em estilo geométrico facetado (low-poly).
"""Gera a logo do Guará: a cabeça do lobo-guará, de frente, recortada das
trilhas de um disco.
A cabeça do lobo-guará foi contornada sobre uma foto de referência, com as
regiões de cor do animal real: focinho escuro subindo até entre os olhos, juba
escura na nuca, interior das orelhas e garganta claros. As facetas (Delaunay)
seguem essas regiões, e o pescoço se solta em estilhaços para a esquerda.
As trilhas são arcos concêntricos com centro abaixo do focinho. Na metade
direita estão inteiras (dados recuperados) e na esquerda quebradas em
fragmentos (dados perdidos). Focinho e olhos usam a cor do texto. As cores
são as do app (apps/gui/ui/app.css): --accent e --accent-2 no tema claro e
seus equivalentes no escuro, trocados por prefers-color-scheme.
Uso: python3 scripts/make-logo.py recorte.png [saida.svg]
Requer numpy, scipy e pillow. O ícone (guara.svg) embute esta mesma arte.
Uso: python3 scripts/make-logo.py [pasta] (padrão: apps/gui/ui)
Grava guara-logo.svg e guara.svg (mesma arte; o segundo é o ícone).
O PNG para os ícones do app (src-tauri/icons/source.png) sai desta arte
renderizada em 1024x1024.
"""
import math, random, sys
import numpy as np
from PIL import Image
from scipy.spatial import Delaunay
OUT=[(98,382),(104,350),(110,318),(114,290),(116,262),(110,235),(100,212),
(84,178),(66,140),(54,100),(50,68),(54,44),(70,52),(98,70),(128,94),(156,118),(176,146),
(180,112),(190,78),(204,50),(216,32),(230,40),(252,64),(274,94),(292,120),(305,135),
(330,138),(370,142),(420,150),(500,165),(500,460),(320,460),(300,420),(260,385),(225,372),(190,380),(150,398),(118,404),(102,396)]
EARS=[[(52,78),(80,96),(115,118),(150,142),(130,170),(105,185),(85,160),(65,120)],
[(222,48),(245,62),(270,95),(285,125),(255,165),(215,165),(195,130),(200,85)]]
EYES=[(125,270),(200,268)]
ZONES=[
# interior claro das orelhas (com borda verde em volta)
('pale',[(62,62),(92,78),(122,100),(150,124),(160,144),(138,166),(116,190),(98,166),(76,124),(62,92)]),
('pale',[(214,50),(228,56),(248,78),(268,106),(282,128),(258,150),(226,160),(200,146),(196,112),(204,76)]),
# testa um pouco mais clara entre as orelhas
('brow',[(160,150),(185,148),(240,170),(270,190),(250,220),(200,230),(160,225),(130,205)]),
# área dos olhos, um tom mais escuro
('mask',[(108,250),(140,250),(165,246),(195,250),(222,262),(220,284),(196,292),(165,282),(140,290),(112,290)]),
# juba escura na nuca
('mane',[(298,136),(500,166),(500,236),(430,214),(360,198),(318,182),(300,160)]),
# garganta clara e linha clara do lábio
('pale',[(214,350),(234,332),(266,324),(302,320),(316,344),(306,372),(274,388),(240,380),(220,370)]),
('pale',[(150,398),(186,382),(212,368),(222,374),(204,388),(166,404)]),
# focinho preto subindo pelo dorso do nariz até entre os olhos
('muzzle',[(96,384),(102,352),(108,322),(114,296),(132,284),(150,266),(164,258),(176,268),(184,294),(196,322),(206,352),(200,374),(170,392),(130,404),(104,398)]),
]
import os, sys
from PIL import ImageFilter
REF = sys.argv[1] # recorte da cabeça da foto de referência (390x460), não versionado
img=np.array(Image.open(REF).convert('RGB').filter(ImageFilter.MedianFilter(9)).filter(ImageFilter.GaussianBlur(4))).astype(float)
Hc,Wc=img.shape[:2]
rnd=random.Random(7)
# contorno: estende o pescoço para a esquerda (depois do espelhamento)
C=[p for p in OUT if p[0]<=500]
def inside(poly,x,y):
c=False; j=len(poly)-1
for i in range(len(poly)):
xi,yi=poly[i]; xj,yj=poly[j]
if (yi>y)!=(yj>y) and x<(xj-xi)*(y-yi)/(yj-yi)+xi: c=not c
j=i
return c
# pontos: contorno reamostrado + traços anatômicos + preenchimento com jitter
pts=[]
for i in range(len(C)):
a=C[i]; b=C[(i+1)%len(C)]; n=max(1,int(math.dist(a,b)/16))
for k in range(n): pts.append((a[0]+(b[0]-a[0])*k/n, a[1]+(b[1]-a[1])*k/n))
FEAT=[(125,270),(200,268),(110,300),(160,286),(185,300),(100,383),(118,404),(150,396),(200,360),
(215,330),(260,322),(300,318),(310,350),(270,386),(140,140),(110,190),(80,120),(255,100),(270,150),(225,160),
(205,110),(175,180),(230,230),(150,230),(300,200),(340,250),(320,170),(360,330),(400,260),(450,330),(260,280)]
pts+=FEAT
# vértices nas bordas das regiões: as facetas seguem os contornos das cores
for k_,Z in ZONES:
for i in range(len(Z)):
a=Z[i]; b=Z[(i+1)%len(Z)]; n=max(1,int(math.dist(a,b)/18))
for j in range(n):
q=(a[0]+(b[0]-a[0])*j/n, a[1]+(b[1]-a[1])*j/n)
if inside(C,*q) and min(math.dist(q,p_) for p_ in pts)>6: pts.append(q)
sp=24
for y in np.arange(20,470,sp):
for x in np.arange(20,510,sp):
jx,jy=x+rnd.uniform(-8,8),y+rnd.uniform(-8,8)
if inside(C,jx,jy) and min(math.dist((jx,jy),p) for p in pts)>15: pts.append((jx,jy))
P=np.array(pts)
tri=Delaunay(P)
def sample(t):
a,b,c=P[t]
cols=[]
for _ in range(40):
u,v=rnd.random(),rnd.random()
if u+v>1: u,v=1-u,1-v
x,y=a+(b-a)*u+(c-a)*v
x=min(max(x,0),Wc-1); y=min(max(y,0),Hc-1)
if x>380: x=380-(x-380)*0.2 # o pescoço além da foto herda a cor da borda
cols.append(img[int(y),int(x)])
m=np.mean(cols,axis=0); return m
RAMP=["#083a45","#0f766e","#14b8a6","#5eead4","#c9faf1"]
def tone(rgb):
r,g,b=rgb; L=(0.299*r+0.587*g+0.114*b)/255
TH=[0.17,0.30,0.50,0.64]
return RAMP[sum(L>t for t in TH)]
def hx(c): return tuple(int(c[i:i+2],16) for i in (1,3,5))
def mix(c1,c2,t):
a,b=hx(c1),hx(c2); return "#"+"".join(f"{round(p+(q-p)*t):02x}" for p,q in zip(a,b))
BASE={'muzzle':("#07323c","#0d5563"),'mane':("#0b4f5c","#0f766e"),'pale':("#9ef0e2","#e3fdf8"),'face':("#0f9e94","#3fdcc8"),'brow':("#1fb9a9","#52dccb"),'mask':("#0c7d76","#139c92")}
def zone_of(x,y):
for k,P_ in reversed(ZONES):
if inside(P_,x,y): return k
return 'face'
F=[]
for t in tri.simplices:
cx,cy=P[t].mean(axis=0)
if not inside(C,cx,cy): continue
z=zone_of(cx,cy)
lo,hi=BASE[z]
# luz vinda do alto e da frente (focinho), com variação sutil por faceta
light=0.55*(1-cy/470)+0.35*(1-min(1,cx/420))+rnd.uniform(-0.12,0.12)
F.append((t, mix(lo,hi,max(0,min(1,light))), cx, cy))
# espelha e encaixa no quadro 160x100 da logo
S=92/430
def T(x,y): return (150-(x-38)*S, 4+(y-30)*S)
out=[]
for t,col,cx,cy in F:
q=[T(*P[i]) for i in t]
# estilhaços: o pescoço (esquerda) se solta e se desfaz
gx=T(cx,cy)[0]
k=max(0,(78-gx)/40)
if k>0 and rnd.random()<min(1,k*1.25):
mx=sum(p[0] for p in q)/3; my=sum(p[1] for p in q)/3
dx=-k*22-rnd.uniform(0,10)*k; dy=-k*6+rnd.uniform(-5,5)*k
sc=max(0.25,1-k*0.8)
q=[(mx+dx+(p[0]-mx)*sc, my+dy+(p[1]-my)*sc) for p in q]
op=max(0.12,1-k*0.95)
else: op=1
out.append(f'<polygon points="{" ".join(f"{x:.2f},{y:.2f}" for x,y in q)}" fill="{col}" stroke="{col}" stroke-width="0.25" stroke-linejoin="round"{"" if op==1 else f" fill-opacity=\"{op:.2f}\" stroke-opacity=\"{op:.2f}\""}/>')
eyes="".join(f'<circle cx="{T(x,y)[0]:.2f}" cy="{T(x,y)[1]:.2f}" r="1.25" fill="#04232b"/>' for x,y in EYES)
open(sys.argv[2] if len(sys.argv) > 2 else 'guara-logo.svg','w').write(f'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 160 100" role="img" aria-label="Guará">{"".join(out)}{eyes}</svg>\n')
HEAD = ("M50 95 C46 88 43 80 40 74 C33 70 25 64 22 56 L14 6 L36 30 "
"C40 28 45 27 50 27 C55 27 60 28 64 30 L86 6 L78 56 "
"C75 64 67 70 60 74 C57 80 54 88 50 95 Z")
STYLE = (".a{stroke:#0f766e}.b{stroke:#14b8a6}.t{fill:#1d1d1f}"
"@media (prefers-color-scheme:dark){.a{stroke:#2dd4bf}.b{stroke:#5eead4}.t{fill:#f5f5f7}}")
def tracks():
out = []
for i, r in enumerate(range(7, 104, 7)):
top, bot = 100 - r, 100 + r
out.append(f'<path class="a" d="M50 {top}A{r} {r} 0 0 1 50 {bot}"/>')
dash = f"{3 + i % 3 * 3} {3 + (i * 5) % 4}"
out.append(f'<path class="b" d="M50 {top}A{r} {r} 0 0 0 50 {bot}" '
f'stroke-dasharray="{dash}" stroke-dashoffset="{i * 3}"/>')
return "".join(out)
def svg():
return (
'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" role="img" aria-label="Guará">'
f'<style>{STYLE}</style>'
f'<defs><clipPath id="g-head"><path d="{HEAD}"/></clipPath></defs>'
f'<g clip-path="url(#g-head)" fill="none" stroke-width="4.2">{tracks()}'
# o focinho é a ponta da própria cabeça (recortada pelo mesmo contorno),
# então nenhuma trilha escapa pelas laterais
'<rect class="t" stroke="none" x="0" y="74" width="100" height="30"/></g>'
'<path class="t" d="M37 50Q42 47 46 52Q41 53 37 50ZM63 50Q58 47 54 52Q59 53 63 50Z"/>'
'</svg>\n'
)
if __name__ == "__main__":
out = sys.argv[1] if len(sys.argv) > 1 else "apps/gui/ui"
for name in ("guara-logo.svg", "guara.svg"):
with open(os.path.join(out, name), "w") as f:
f.write(svg())