├── .gitignore ├── Cargo.lock ├── Cargo.toml ├── assets └── preview_sample.png ├── examples └── sample.lua ├── license ├── readme.md └── src ├── main.rs ├── modules ├── cpu.rs ├── disk.rs ├── host.rs ├── hostname.rs ├── kernel.rs ├── mem.rs ├── mod.rs ├── os.rs ├── uptime.rs └── user.rs └── yafetch.rs /.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | -------------------------------------------------------------------------------- /Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | version = 3 4 | 5 | [[package]] 6 | name = "anyhow" 7 | version = "1.0.80" 8 | source = "registry+https://github.com/rust-lang/crates.io-index" 9 | checksum = "5ad32ce52e4161730f7098c077cd2ed6229b5804ccf99e5366be1ab72a98b4e1" 10 | 11 | [[package]] 12 | name = "autocfg" 13 | version = "1.1.0" 14 | source = "registry+https://github.com/rust-lang/crates.io-index" 15 | checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" 16 | 17 | [[package]] 18 | name = "bitflags" 19 | version = "1.3.2" 20 | source = "registry+https://github.com/rust-lang/crates.io-index" 21 | checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" 22 | 23 | [[package]] 24 | name = "bitflags" 25 | version = "2.4.2" 26 | source = "registry+https://github.com/rust-lang/crates.io-index" 27 | checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf" 28 | 29 | [[package]] 30 | name = "bstr" 31 | version = "1.9.0" 32 | source = "registry+https://github.com/rust-lang/crates.io-index" 33 | checksum = "c48f0051a4b4c5e0b6d365cd04af53aeaa209e3cc15ec2cdb69e73cc87fbd0dc" 34 | dependencies = [ 35 | "memchr", 36 | "serde", 37 | ] 38 | 39 | [[package]] 40 | name = "bumpalo" 41 | version = "3.16.0" 42 | source = "registry+https://github.com/rust-lang/crates.io-index" 43 | checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" 44 | 45 | [[package]] 46 | name = "bytesize" 47 | version = "1.3.0" 48 | source = "registry+https://github.com/rust-lang/crates.io-index" 49 | checksum = "a3e368af43e418a04d52505cf3dbc23dda4e3407ae2fa99fd0e4f308ce546acc" 50 | 51 | [[package]] 52 | name = "cc" 53 | version = "1.0.83" 54 | source = "registry+https://github.com/rust-lang/crates.io-index" 55 | checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0" 56 | dependencies = [ 57 | "libc", 58 | ] 59 | 60 | [[package]] 61 | name = "cfg-if" 62 | version = "1.0.0" 63 | source = "registry+https://github.com/rust-lang/crates.io-index" 64 | checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" 65 | 66 | [[package]] 67 | name = "core-foundation-sys" 68 | version = "0.8.6" 69 | source = "registry+https://github.com/rust-lang/crates.io-index" 70 | checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f" 71 | 72 | [[package]] 73 | name = "crossbeam-deque" 74 | version = "0.8.5" 75 | source = "registry+https://github.com/rust-lang/crates.io-index" 76 | checksum = "613f8cc01fe9cf1a3eb3d7f488fd2fa8388403e97039e2f73692932e291a770d" 77 | dependencies = [ 78 | "crossbeam-epoch", 79 | "crossbeam-utils", 80 | ] 81 | 82 | [[package]] 83 | name = "crossbeam-epoch" 84 | version = "0.9.18" 85 | source = "registry+https://github.com/rust-lang/crates.io-index" 86 | checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e" 87 | dependencies = [ 88 | "crossbeam-utils", 89 | ] 90 | 91 | [[package]] 92 | name = "crossbeam-utils" 93 | version = "0.8.19" 94 | source = "registry+https://github.com/rust-lang/crates.io-index" 95 | checksum = "248e3bacc7dc6baa3b21e405ee045c3047101a49145e7e9eca583ab4c2ca5345" 96 | 97 | [[package]] 98 | name = "darling" 99 | version = "0.20.6" 100 | source = "registry+https://github.com/rust-lang/crates.io-index" 101 | checksum = "c376d08ea6aa96aafe61237c7200d1241cb177b7d3a542d791f2d118e9cbb955" 102 | dependencies = [ 103 | "darling_core", 104 | "darling_macro", 105 | ] 106 | 107 | [[package]] 108 | name = "darling_core" 109 | version = "0.20.6" 110 | source = "registry+https://github.com/rust-lang/crates.io-index" 111 | checksum = "33043dcd19068b8192064c704b3f83eb464f91f1ff527b44a4e2b08d9cdb8855" 112 | dependencies = [ 113 | "fnv", 114 | "ident_case", 115 | "proc-macro2", 116 | "quote", 117 | "strsim", 118 | "syn", 119 | ] 120 | 121 | [[package]] 122 | name = "darling_macro" 123 | version = "0.20.6" 124 | source = "registry+https://github.com/rust-lang/crates.io-index" 125 | checksum = "c5a91391accf613803c2a9bf9abccdbaa07c54b4244a5b64883f9c3c137c86be" 126 | dependencies = [ 127 | "darling_core", 128 | "quote", 129 | "syn", 130 | ] 131 | 132 | [[package]] 133 | name = "deranged" 134 | version = "0.3.11" 135 | source = "registry+https://github.com/rust-lang/crates.io-index" 136 | checksum = "b42b6fa04a440b495c8b04d0e71b707c585f83cb9cb28cf8cd0d976c315e31b4" 137 | dependencies = [ 138 | "powerfmt", 139 | ] 140 | 141 | [[package]] 142 | name = "either" 143 | version = "1.10.0" 144 | source = "registry+https://github.com/rust-lang/crates.io-index" 145 | checksum = "11157ac094ffbdde99aa67b23417ebdd801842852b500e395a45a9c0aac03e4a" 146 | 147 | [[package]] 148 | name = "errno" 149 | version = "0.3.8" 150 | source = "registry+https://github.com/rust-lang/crates.io-index" 151 | checksum = "a258e46cdc063eb8519c00b9fc845fc47bcfca4130e2f08e88665ceda8474245" 152 | dependencies = [ 153 | "libc", 154 | "windows-sys", 155 | ] 156 | 157 | [[package]] 158 | name = "fnv" 159 | version = "1.0.7" 160 | source = "registry+https://github.com/rust-lang/crates.io-index" 161 | checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" 162 | 163 | [[package]] 164 | name = "fs2" 165 | version = "0.4.3" 166 | source = "registry+https://github.com/rust-lang/crates.io-index" 167 | checksum = "9564fc758e15025b46aa6643b1b77d047d1a56a1aea6e01002ac0c7026876213" 168 | dependencies = [ 169 | "libc", 170 | "winapi", 171 | ] 172 | 173 | [[package]] 174 | name = "home" 175 | version = "0.5.9" 176 | source = "registry+https://github.com/rust-lang/crates.io-index" 177 | checksum = "e3d1354bf6b7235cb4a0576c2619fd4ed18183f689b12b006a0ee7329eeff9a5" 178 | dependencies = [ 179 | "windows-sys", 180 | ] 181 | 182 | [[package]] 183 | name = "ident_case" 184 | version = "1.0.1" 185 | source = "registry+https://github.com/rust-lang/crates.io-index" 186 | checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" 187 | 188 | [[package]] 189 | name = "js-sys" 190 | version = "0.3.70" 191 | source = "registry+https://github.com/rust-lang/crates.io-index" 192 | checksum = "1868808506b929d7b0cfa8f75951347aa71bb21144b7791bae35d9bccfcfe37a" 193 | dependencies = [ 194 | "wasm-bindgen", 195 | ] 196 | 197 | [[package]] 198 | name = "lazy_static" 199 | version = "1.4.0" 200 | source = "registry+https://github.com/rust-lang/crates.io-index" 201 | checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" 202 | 203 | [[package]] 204 | name = "libc" 205 | version = "0.2.153" 206 | source = "registry+https://github.com/rust-lang/crates.io-index" 207 | checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" 208 | 209 | [[package]] 210 | name = "libloading" 211 | version = "0.7.4" 212 | source = "registry+https://github.com/rust-lang/crates.io-index" 213 | checksum = "b67380fd3b2fbe7527a606e18729d21c6f3951633d0500574c4dc22d2d638b9f" 214 | dependencies = [ 215 | "cfg-if", 216 | "winapi", 217 | ] 218 | 219 | [[package]] 220 | name = "linux-raw-sys" 221 | version = "0.4.13" 222 | source = "registry+https://github.com/rust-lang/crates.io-index" 223 | checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c" 224 | 225 | [[package]] 226 | name = "log" 227 | version = "0.4.20" 228 | source = "registry+https://github.com/rust-lang/crates.io-index" 229 | checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" 230 | 231 | [[package]] 232 | name = "lua-src" 233 | version = "546.0.2" 234 | source = "registry+https://github.com/rust-lang/crates.io-index" 235 | checksum = "2da0daa7eee611a4c30c8f5ee31af55266e26e573971ba9336d2993e2da129b2" 236 | dependencies = [ 237 | "cc", 238 | ] 239 | 240 | [[package]] 241 | name = "luajit-src" 242 | version = "210.5.6+9cc2e42" 243 | source = "registry+https://github.com/rust-lang/crates.io-index" 244 | checksum = "23b365d859c9ffc187f48bb3e25ec80c3b40cf3f68f53544f4adeaee70554157" 245 | dependencies = [ 246 | "cc", 247 | "which", 248 | ] 249 | 250 | [[package]] 251 | name = "machine-info" 252 | version = "1.0.9" 253 | source = "registry+https://github.com/rust-lang/crates.io-index" 254 | checksum = "2d0bcde250f7927612edb0807ada4ad1d92915d9632d917df9bf696e74095dce" 255 | dependencies = [ 256 | "anyhow", 257 | "log", 258 | "nvml-wrapper", 259 | "serde", 260 | "sysinfo 0.26.9", 261 | ] 262 | 263 | [[package]] 264 | name = "memchr" 265 | version = "2.7.1" 266 | source = "registry+https://github.com/rust-lang/crates.io-index" 267 | checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149" 268 | 269 | [[package]] 270 | name = "minimal-lexical" 271 | version = "0.2.1" 272 | source = "registry+https://github.com/rust-lang/crates.io-index" 273 | checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" 274 | 275 | [[package]] 276 | name = "mlua" 277 | version = "0.9.5" 278 | source = "registry+https://github.com/rust-lang/crates.io-index" 279 | checksum = "1d3561f79659ff3afad7b25e2bf2ec21507fe601ebecb7f81088669ec4bfd51e" 280 | dependencies = [ 281 | "bstr", 282 | "mlua-sys", 283 | "num-traits", 284 | "once_cell", 285 | "rustc-hash", 286 | ] 287 | 288 | [[package]] 289 | name = "mlua-sys" 290 | version = "0.5.1" 291 | source = "registry+https://github.com/rust-lang/crates.io-index" 292 | checksum = "2847b42764435201d8cbee1f517edb79c4cca4181877b90047587c89e1b7bce4" 293 | dependencies = [ 294 | "cc", 295 | "cfg-if", 296 | "lua-src", 297 | "luajit-src", 298 | "pkg-config", 299 | ] 300 | 301 | [[package]] 302 | name = "nom" 303 | version = "7.1.3" 304 | source = "registry+https://github.com/rust-lang/crates.io-index" 305 | checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" 306 | dependencies = [ 307 | "memchr", 308 | "minimal-lexical", 309 | ] 310 | 311 | [[package]] 312 | name = "ntapi" 313 | version = "0.4.1" 314 | source = "registry+https://github.com/rust-lang/crates.io-index" 315 | checksum = "e8a3895c6391c39d7fe7ebc444a87eb2991b2a0bc718fdabd071eec617fc68e4" 316 | dependencies = [ 317 | "winapi", 318 | ] 319 | 320 | [[package]] 321 | name = "num-conv" 322 | version = "0.1.0" 323 | source = "registry+https://github.com/rust-lang/crates.io-index" 324 | checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" 325 | 326 | [[package]] 327 | name = "num-traits" 328 | version = "0.2.18" 329 | source = "registry+https://github.com/rust-lang/crates.io-index" 330 | checksum = "da0df0e5185db44f69b44f26786fe401b6c293d1907744beaa7fa62b2e5a517a" 331 | dependencies = [ 332 | "autocfg", 333 | ] 334 | 335 | [[package]] 336 | name = "nvml-wrapper" 337 | version = "0.8.0" 338 | source = "registry+https://github.com/rust-lang/crates.io-index" 339 | checksum = "288bd66a5a56d8c97b178412b328419b3fdec261c0cbc4628ddc49cc16db8fc6" 340 | dependencies = [ 341 | "bitflags 1.3.2", 342 | "libloading", 343 | "nvml-wrapper-sys", 344 | "static_assertions", 345 | "thiserror", 346 | "wrapcenum-derive", 347 | ] 348 | 349 | [[package]] 350 | name = "nvml-wrapper-sys" 351 | version = "0.6.0" 352 | source = "registry+https://github.com/rust-lang/crates.io-index" 353 | checksum = "d3d606d4edf766969f16828ec047ca9aa96652a17bd353dc0613bfaca49b61d6" 354 | dependencies = [ 355 | "libloading", 356 | ] 357 | 358 | [[package]] 359 | name = "once_cell" 360 | version = "1.19.0" 361 | source = "registry+https://github.com/rust-lang/crates.io-index" 362 | checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" 363 | 364 | [[package]] 365 | name = "pkg-config" 366 | version = "0.3.30" 367 | source = "registry+https://github.com/rust-lang/crates.io-index" 368 | checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" 369 | 370 | [[package]] 371 | name = "powerfmt" 372 | version = "0.2.0" 373 | source = "registry+https://github.com/rust-lang/crates.io-index" 374 | checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" 375 | 376 | [[package]] 377 | name = "proc-macro2" 378 | version = "1.0.78" 379 | source = "registry+https://github.com/rust-lang/crates.io-index" 380 | checksum = "e2422ad645d89c99f8f3e6b88a9fdeca7fabeac836b1002371c4367c8f984aae" 381 | dependencies = [ 382 | "unicode-ident", 383 | ] 384 | 385 | [[package]] 386 | name = "quote" 387 | version = "1.0.35" 388 | source = "registry+https://github.com/rust-lang/crates.io-index" 389 | checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" 390 | dependencies = [ 391 | "proc-macro2", 392 | ] 393 | 394 | [[package]] 395 | name = "rayon" 396 | version = "1.8.1" 397 | source = "registry+https://github.com/rust-lang/crates.io-index" 398 | checksum = "fa7237101a77a10773db45d62004a272517633fbcc3df19d96455ede1122e051" 399 | dependencies = [ 400 | "either", 401 | "rayon-core", 402 | ] 403 | 404 | [[package]] 405 | name = "rayon-core" 406 | version = "1.12.1" 407 | source = "registry+https://github.com/rust-lang/crates.io-index" 408 | checksum = "1465873a3dfdaa8ae7cb14b4383657caab0b3e8a0aa9ae8e04b044854c8dfce2" 409 | dependencies = [ 410 | "crossbeam-deque", 411 | "crossbeam-utils", 412 | ] 413 | 414 | [[package]] 415 | name = "redox_syscall" 416 | version = "0.5.7" 417 | source = "registry+https://github.com/rust-lang/crates.io-index" 418 | checksum = "9b6dfecf2c74bce2466cabf93f6664d6998a69eb21e39f4207930065b27b771f" 419 | dependencies = [ 420 | "bitflags 2.4.2", 421 | ] 422 | 423 | [[package]] 424 | name = "rustc-hash" 425 | version = "1.1.0" 426 | source = "registry+https://github.com/rust-lang/crates.io-index" 427 | checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" 428 | 429 | [[package]] 430 | name = "rustix" 431 | version = "0.38.31" 432 | source = "registry+https://github.com/rust-lang/crates.io-index" 433 | checksum = "6ea3e1a662af26cd7a3ba09c0297a31af215563ecf42817c98df621387f4e949" 434 | dependencies = [ 435 | "bitflags 2.4.2", 436 | "errno", 437 | "libc", 438 | "linux-raw-sys", 439 | "windows-sys", 440 | ] 441 | 442 | [[package]] 443 | name = "serde" 444 | version = "1.0.197" 445 | source = "registry+https://github.com/rust-lang/crates.io-index" 446 | checksum = "3fb1c873e1b9b056a4dc4c0c198b24c3ffa059243875552b2bd0933b1aee4ce2" 447 | dependencies = [ 448 | "serde_derive", 449 | ] 450 | 451 | [[package]] 452 | name = "serde_derive" 453 | version = "1.0.197" 454 | source = "registry+https://github.com/rust-lang/crates.io-index" 455 | checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" 456 | dependencies = [ 457 | "proc-macro2", 458 | "quote", 459 | "syn", 460 | ] 461 | 462 | [[package]] 463 | name = "static_assertions" 464 | version = "1.1.0" 465 | source = "registry+https://github.com/rust-lang/crates.io-index" 466 | checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" 467 | 468 | [[package]] 469 | name = "strsim" 470 | version = "0.10.0" 471 | source = "registry+https://github.com/rust-lang/crates.io-index" 472 | checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" 473 | 474 | [[package]] 475 | name = "syn" 476 | version = "2.0.50" 477 | source = "registry+https://github.com/rust-lang/crates.io-index" 478 | checksum = "74f1bdc9872430ce9b75da68329d1c1746faf50ffac5f19e02b71e37ff881ffb" 479 | dependencies = [ 480 | "proc-macro2", 481 | "quote", 482 | "unicode-ident", 483 | ] 484 | 485 | [[package]] 486 | name = "sysinfo" 487 | version = "0.26.9" 488 | source = "registry+https://github.com/rust-lang/crates.io-index" 489 | checksum = "5c18a6156d1f27a9592ee18c1a846ca8dd5c258b7179fc193ae87c74ebb666f5" 490 | dependencies = [ 491 | "cfg-if", 492 | "core-foundation-sys", 493 | "libc", 494 | "ntapi", 495 | "once_cell", 496 | "winapi", 497 | ] 498 | 499 | [[package]] 500 | name = "sysinfo" 501 | version = "0.30.5" 502 | source = "registry+https://github.com/rust-lang/crates.io-index" 503 | checksum = "1fb4f3438c8f6389c864e61221cbc97e9bca98b4daf39a5beb7bea660f528bb2" 504 | dependencies = [ 505 | "cfg-if", 506 | "core-foundation-sys", 507 | "libc", 508 | "ntapi", 509 | "once_cell", 510 | "rayon", 511 | "windows", 512 | ] 513 | 514 | [[package]] 515 | name = "systemstat" 516 | version = "0.2.3" 517 | source = "registry+https://github.com/rust-lang/crates.io-index" 518 | checksum = "a24aec24a9312c83999a28e3ef9db7e2afd5c64bf47725b758cdc1cafd5b0bd2" 519 | dependencies = [ 520 | "bytesize", 521 | "lazy_static", 522 | "libc", 523 | "nom", 524 | "time", 525 | "winapi", 526 | ] 527 | 528 | [[package]] 529 | name = "thiserror" 530 | version = "1.0.57" 531 | source = "registry+https://github.com/rust-lang/crates.io-index" 532 | checksum = "1e45bcbe8ed29775f228095caf2cd67af7a4ccf756ebff23a306bf3e8b47b24b" 533 | dependencies = [ 534 | "thiserror-impl", 535 | ] 536 | 537 | [[package]] 538 | name = "thiserror-impl" 539 | version = "1.0.57" 540 | source = "registry+https://github.com/rust-lang/crates.io-index" 541 | checksum = "a953cb265bef375dae3de6663da4d3804eee9682ea80d8e2542529b73c531c81" 542 | dependencies = [ 543 | "proc-macro2", 544 | "quote", 545 | "syn", 546 | ] 547 | 548 | [[package]] 549 | name = "time" 550 | version = "0.3.34" 551 | source = "registry+https://github.com/rust-lang/crates.io-index" 552 | checksum = "c8248b6521bb14bc45b4067159b9b6ad792e2d6d754d6c41fb50e29fefe38749" 553 | dependencies = [ 554 | "deranged", 555 | "num-conv", 556 | "powerfmt", 557 | "serde", 558 | "time-core", 559 | ] 560 | 561 | [[package]] 562 | name = "time-core" 563 | version = "0.1.2" 564 | source = "registry+https://github.com/rust-lang/crates.io-index" 565 | checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" 566 | 567 | [[package]] 568 | name = "unicode-ident" 569 | version = "1.0.12" 570 | source = "registry+https://github.com/rust-lang/crates.io-index" 571 | checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" 572 | 573 | [[package]] 574 | name = "wasite" 575 | version = "0.1.0" 576 | source = "registry+https://github.com/rust-lang/crates.io-index" 577 | checksum = "b8dad83b4f25e74f184f64c43b150b91efe7647395b42289f38e50566d82855b" 578 | 579 | [[package]] 580 | name = "wasm-bindgen" 581 | version = "0.2.93" 582 | source = "registry+https://github.com/rust-lang/crates.io-index" 583 | checksum = "a82edfc16a6c469f5f44dc7b571814045d60404b55a0ee849f9bcfa2e63dd9b5" 584 | dependencies = [ 585 | "cfg-if", 586 | "once_cell", 587 | "wasm-bindgen-macro", 588 | ] 589 | 590 | [[package]] 591 | name = "wasm-bindgen-backend" 592 | version = "0.2.93" 593 | source = "registry+https://github.com/rust-lang/crates.io-index" 594 | checksum = "9de396da306523044d3302746f1208fa71d7532227f15e347e2d93e4145dd77b" 595 | dependencies = [ 596 | "bumpalo", 597 | "log", 598 | "once_cell", 599 | "proc-macro2", 600 | "quote", 601 | "syn", 602 | "wasm-bindgen-shared", 603 | ] 604 | 605 | [[package]] 606 | name = "wasm-bindgen-macro" 607 | version = "0.2.93" 608 | source = "registry+https://github.com/rust-lang/crates.io-index" 609 | checksum = "585c4c91a46b072c92e908d99cb1dcdf95c5218eeb6f3bf1efa991ee7a68cccf" 610 | dependencies = [ 611 | "quote", 612 | "wasm-bindgen-macro-support", 613 | ] 614 | 615 | [[package]] 616 | name = "wasm-bindgen-macro-support" 617 | version = "0.2.93" 618 | source = "registry+https://github.com/rust-lang/crates.io-index" 619 | checksum = "afc340c74d9005395cf9dd098506f7f44e38f2b4a21c6aaacf9a105ea5e1e836" 620 | dependencies = [ 621 | "proc-macro2", 622 | "quote", 623 | "syn", 624 | "wasm-bindgen-backend", 625 | "wasm-bindgen-shared", 626 | ] 627 | 628 | [[package]] 629 | name = "wasm-bindgen-shared" 630 | version = "0.2.93" 631 | source = "registry+https://github.com/rust-lang/crates.io-index" 632 | checksum = "c62a0a307cb4a311d3a07867860911ca130c3494e8c2719593806c08bc5d0484" 633 | 634 | [[package]] 635 | name = "web-sys" 636 | version = "0.3.70" 637 | source = "registry+https://github.com/rust-lang/crates.io-index" 638 | checksum = "26fdeaafd9bd129f65e7c031593c24d62186301e0c72c8978fa1678be7d532c0" 639 | dependencies = [ 640 | "js-sys", 641 | "wasm-bindgen", 642 | ] 643 | 644 | [[package]] 645 | name = "which" 646 | version = "6.0.0" 647 | source = "registry+https://github.com/rust-lang/crates.io-index" 648 | checksum = "7fa5e0c10bf77f44aac573e498d1a82d5fbd5e91f6fc0a99e7be4b38e85e101c" 649 | dependencies = [ 650 | "either", 651 | "home", 652 | "once_cell", 653 | "rustix", 654 | "windows-sys", 655 | ] 656 | 657 | [[package]] 658 | name = "whoami" 659 | version = "1.5.2" 660 | source = "registry+https://github.com/rust-lang/crates.io-index" 661 | checksum = "372d5b87f58ec45c384ba03563b03544dc5fadc3983e434b286913f5b4a9bb6d" 662 | dependencies = [ 663 | "redox_syscall", 664 | "wasite", 665 | "web-sys", 666 | ] 667 | 668 | [[package]] 669 | name = "winapi" 670 | version = "0.3.9" 671 | source = "registry+https://github.com/rust-lang/crates.io-index" 672 | checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" 673 | dependencies = [ 674 | "winapi-i686-pc-windows-gnu", 675 | "winapi-x86_64-pc-windows-gnu", 676 | ] 677 | 678 | [[package]] 679 | name = "winapi-i686-pc-windows-gnu" 680 | version = "0.4.0" 681 | source = "registry+https://github.com/rust-lang/crates.io-index" 682 | checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" 683 | 684 | [[package]] 685 | name = "winapi-x86_64-pc-windows-gnu" 686 | version = "0.4.0" 687 | source = "registry+https://github.com/rust-lang/crates.io-index" 688 | checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" 689 | 690 | [[package]] 691 | name = "windows" 692 | version = "0.52.0" 693 | source = "registry+https://github.com/rust-lang/crates.io-index" 694 | checksum = "e48a53791691ab099e5e2ad123536d0fff50652600abaf43bbf952894110d0be" 695 | dependencies = [ 696 | "windows-core", 697 | "windows-targets", 698 | ] 699 | 700 | [[package]] 701 | name = "windows-core" 702 | version = "0.52.0" 703 | source = "registry+https://github.com/rust-lang/crates.io-index" 704 | checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" 705 | dependencies = [ 706 | "windows-targets", 707 | ] 708 | 709 | [[package]] 710 | name = "windows-sys" 711 | version = "0.52.0" 712 | source = "registry+https://github.com/rust-lang/crates.io-index" 713 | checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" 714 | dependencies = [ 715 | "windows-targets", 716 | ] 717 | 718 | [[package]] 719 | name = "windows-targets" 720 | version = "0.52.0" 721 | source = "registry+https://github.com/rust-lang/crates.io-index" 722 | checksum = "8a18201040b24831fbb9e4eb208f8892e1f50a37feb53cc7ff887feb8f50e7cd" 723 | dependencies = [ 724 | "windows_aarch64_gnullvm", 725 | "windows_aarch64_msvc", 726 | "windows_i686_gnu", 727 | "windows_i686_msvc", 728 | "windows_x86_64_gnu", 729 | "windows_x86_64_gnullvm", 730 | "windows_x86_64_msvc", 731 | ] 732 | 733 | [[package]] 734 | name = "windows_aarch64_gnullvm" 735 | version = "0.52.0" 736 | source = "registry+https://github.com/rust-lang/crates.io-index" 737 | checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea" 738 | 739 | [[package]] 740 | name = "windows_aarch64_msvc" 741 | version = "0.52.0" 742 | source = "registry+https://github.com/rust-lang/crates.io-index" 743 | checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef" 744 | 745 | [[package]] 746 | name = "windows_i686_gnu" 747 | version = "0.52.0" 748 | source = "registry+https://github.com/rust-lang/crates.io-index" 749 | checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313" 750 | 751 | [[package]] 752 | name = "windows_i686_msvc" 753 | version = "0.52.0" 754 | source = "registry+https://github.com/rust-lang/crates.io-index" 755 | checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a" 756 | 757 | [[package]] 758 | name = "windows_x86_64_gnu" 759 | version = "0.52.0" 760 | source = "registry+https://github.com/rust-lang/crates.io-index" 761 | checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd" 762 | 763 | [[package]] 764 | name = "windows_x86_64_gnullvm" 765 | version = "0.52.0" 766 | source = "registry+https://github.com/rust-lang/crates.io-index" 767 | checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e" 768 | 769 | [[package]] 770 | name = "windows_x86_64_msvc" 771 | version = "0.52.0" 772 | source = "registry+https://github.com/rust-lang/crates.io-index" 773 | checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" 774 | 775 | [[package]] 776 | name = "wrapcenum-derive" 777 | version = "0.4.1" 778 | source = "registry+https://github.com/rust-lang/crates.io-index" 779 | checksum = "a76ff259533532054cfbaefb115c613203c73707017459206380f03b3b3f266e" 780 | dependencies = [ 781 | "darling", 782 | "proc-macro2", 783 | "quote", 784 | "syn", 785 | ] 786 | 787 | [[package]] 788 | name = "xdg" 789 | version = "2.5.2" 790 | source = "registry+https://github.com/rust-lang/crates.io-index" 791 | checksum = "213b7324336b53d2414b2db8537e56544d981803139155afa84f76eeebb7a546" 792 | 793 | [[package]] 794 | name = "yafetch" 795 | version = "0.1.0" 796 | dependencies = [ 797 | "bytesize", 798 | "fs2", 799 | "machine-info", 800 | "mlua", 801 | "sysinfo 0.30.5", 802 | "systemstat", 803 | "whoami", 804 | "xdg", 805 | ] 806 | -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "yafetch" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | [dependencies] 7 | bytesize = "1.3.0" 8 | fs2 = "0.4.3" 9 | machine-info = "1.0.9" 10 | mlua = { version = "0.9.1", features = ["lua54", "vendored"] } 11 | sysinfo = "0.30.5" 12 | systemstat = "0.2.3" 13 | xdg = "2.5.2" 14 | whoami = "1.5.2" 15 | -------------------------------------------------------------------------------- /assets/preview_sample.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yrwq/yafetch/de18a135a51459674add5dacba68592a2af18d5f/assets/preview_sample.png -------------------------------------------------------------------------------- /examples/sample.lua: -------------------------------------------------------------------------------- 1 | local red = "\27[31m" 2 | local grn = "\27[32m" 3 | local yel = "\27[33m" 4 | local blu = "\27[34m" 5 | local mag = "\27[35m" 6 | local wht = "\27[37m" 7 | local bold = "\27[1m" 8 | local res = "\27[0m" 9 | 10 | local header = bold .. mag .. yafetch.user() .. res .. bold .. "@" .. bold .. mag .. yafetch.hostname() .. res 11 | 12 | local used_ssd = yafetch.disk_total("/") - yafetch.disk_free("/") 13 | 14 | print(header) 15 | print(yel .. "distro " .. res .. bold .. yafetch.os() .. res) 16 | print(yel .. "host " .. res .. bold .. yafetch.host() .. res) 17 | print(yel .. "uptime " .. res .. bold .. yafetch.uptime() .. res) 18 | print(yel .. "kernel " .. res .. bold .. yafetch.kernel() .. res) 19 | print(yel .. "cpu " .. res .. bold .. yafetch.cpu() .. res) 20 | print(yel .. "disk " .. res .. bold .. used_ssd .. "gb / " .. yafetch.disk_total("/") .. "gb" .. res) 21 | print(yel .. "memory " .. res .. bold .. yafetch.mem_used() .. "gb / " .. yafetch.mem_total() .. "gb" .. res) 22 | -------------------------------------------------------------------------------- /license: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 David Inhof 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 |

2 | 3 |

4 | 5 |

Yafetch is a minimal command line system information tool written in Rust and configured in Lua.

6 | 7 | ## installation 8 | 9 | ```bash 10 | git clone https://github.com/yrwq/yafetch && cd yafetch 11 | cargo build --release 12 | sudo cp target/release/yafetch /usr/bin 13 | mkdir -p ~/.config/yafetch 14 | cp examples/sample.lua ~/.config/yafetch/init.lua 15 | ``` 16 | 17 | ## usage 18 | 19 | run `yafetch` 20 | 21 | yafetch is extensible in lua, the default location for the configuration file is `~/.config/yafetch/init.lua`. 22 | 23 | ## configuration 24 | -------------------------------------------------------------------------------- /src/main.rs: -------------------------------------------------------------------------------- 1 | pub mod modules; 2 | mod yafetch; 3 | use mlua::Lua; 4 | 5 | /// try to get the user's config 6 | fn get_config() -> std::path::PathBuf { 7 | let xdg_dirs = xdg::BaseDirectories::with_prefix("yafetch").unwrap(); 8 | let config_path = xdg_dirs 9 | .find_config_file("init.lua") 10 | .expect("could not find init.lua in ~/.config/yafetch"); 11 | return config_path; 12 | } 13 | 14 | fn main() { 15 | // initialize yafetch with a lua state 16 | let yf = yafetch::Yafetch { lua: Lua::new() }; 17 | 18 | // register functions 19 | yf.register(); 20 | 21 | let args: Vec = std::env::args().collect(); 22 | 23 | match args.len() { 24 | // no argument passed 25 | 1 => { 26 | yf.run(get_config()); 27 | } 28 | 2 => { 29 | yf.run(args[1].clone().into()); 30 | } 31 | _ => { 32 | // TODO: help message 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/modules/cpu.rs: -------------------------------------------------------------------------------- 1 | use sysinfo::{CpuRefreshKind, RefreshKind, System}; 2 | 3 | /// Returns the cpu vendor and brand 4 | pub fn get() -> String { 5 | let s = System::new_with_specifics(RefreshKind::new().with_cpu(CpuRefreshKind::everything())); 6 | 7 | let cpu = s.cpus().first(); 8 | let brand = cpu.unwrap().brand().to_string(); 9 | let vendor = cpu.unwrap().vendor_id().to_string(); 10 | let result = format!("{vendor} {brand}"); 11 | return result; 12 | } 13 | -------------------------------------------------------------------------------- /src/modules/disk.rs: -------------------------------------------------------------------------------- 1 | use fs2; 2 | 3 | pub fn get_total(path: String) -> String { 4 | 5 | let total = fs2::total_space(path).unwrap(); 6 | 7 | let total_gb = total / 1024 / 1024 / 1024; 8 | return total_gb.to_string(); 9 | } 10 | 11 | pub fn get_free(path: String) -> String { 12 | 13 | let free = fs2::available_space(path).unwrap(); 14 | let free_gb = free / 1024 / 1024 / 1024; 15 | 16 | return free_gb.to_string(); 17 | } 18 | -------------------------------------------------------------------------------- /src/modules/host.rs: -------------------------------------------------------------------------------- 1 | use std::fs; 2 | 3 | /// Returns the cpu vendor and brand 4 | pub fn get() -> String { 5 | let mut path = "/sys/devices/virtual/dmi/id/product_name"; 6 | if fs::metadata(path).is_err() { 7 | path = "/sys/firmware/devicetree/base/model"; 8 | } 9 | 10 | let f = fs::read_to_string(path); 11 | return f.unwrap(); 12 | } 13 | -------------------------------------------------------------------------------- /src/modules/hostname.rs: -------------------------------------------------------------------------------- 1 | pub fn get() -> String { 2 | let hostname = std::fs::read_to_string("/etc/hostname") 3 | .expect("could not read /etc/hostname"); 4 | return hostname.trim().to_string(); 5 | } 6 | -------------------------------------------------------------------------------- /src/modules/kernel.rs: -------------------------------------------------------------------------------- 1 | use sysinfo::System; 2 | 3 | pub fn get() -> String { 4 | let mut sys = System::new_all(); 5 | 6 | sys.refresh_all(); 7 | 8 | return System::kernel_version().unwrap() 9 | } 10 | -------------------------------------------------------------------------------- /src/modules/mem.rs: -------------------------------------------------------------------------------- 1 | use sysinfo::System; 2 | use bytesize::ByteSize; 3 | 4 | pub fn get_used() -> String { 5 | let mut sys = System::new_all(); 6 | sys.refresh_all(); 7 | 8 | let mem = ByteSize::gb(sys.used_memory()).to_string(); 9 | let mut split_mem = mem.split(" "); 10 | // 11 | let total = split_mem.nth(0).unwrap(); 12 | 13 | return total.to_string(); 14 | } 15 | 16 | pub fn get_total() -> String { 17 | let mut sys = System::new_all(); 18 | sys.refresh_all(); 19 | 20 | let mem = ByteSize::gb(sys.total_memory()).to_string(); 21 | let mut split_mem = mem.split(" "); 22 | // 23 | let total = split_mem.nth(0).unwrap(); 24 | 25 | return total.to_string(); 26 | } 27 | -------------------------------------------------------------------------------- /src/modules/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod cpu; 2 | pub mod disk; 3 | pub mod host; 4 | pub mod hostname; 5 | pub mod kernel; 6 | pub mod mem; 7 | pub mod os; 8 | pub mod uptime; 9 | pub mod user; 10 | -------------------------------------------------------------------------------- /src/modules/os.rs: -------------------------------------------------------------------------------- 1 | use sysinfo::System; 2 | 3 | pub fn get() -> String { 4 | return System::name().unwrap(); 5 | } 6 | -------------------------------------------------------------------------------- /src/modules/uptime.rs: -------------------------------------------------------------------------------- 1 | use systemstat::Platform; 2 | 3 | pub fn get() -> String { 4 | let stat = systemstat::System::new(); 5 | let upt = stat.uptime().unwrap(); 6 | let uptime_seconds = upt.as_secs(); 7 | 8 | 9 | // Calculate the uptime in hours and minutes respectively 10 | let uptime_hours = uptime_seconds / (60 * 60); 11 | let uptime_minutes = (uptime_seconds % (60 * 60)) / 60; 12 | let mut hstr = uptime_hours.to_string(); 13 | let mut mstr = uptime_minutes.to_string(); 14 | 15 | hstr.push_str("h "); 16 | mstr.push_str("m"); 17 | hstr.push_str(&mstr); 18 | 19 | if uptime_hours == 0 { 20 | return mstr; 21 | } 22 | 23 | return hstr; 24 | } 25 | -------------------------------------------------------------------------------- /src/modules/user.rs: -------------------------------------------------------------------------------- 1 | use std::env; 2 | 3 | pub fn get() -> String { 4 | env::var("USER").unwrap() 5 | } 6 | -------------------------------------------------------------------------------- /src/yafetch.rs: -------------------------------------------------------------------------------- 1 | use mlua::prelude::*; 2 | 3 | use crate::modules; 4 | 5 | pub struct Yafetch { 6 | pub lua: Lua, 7 | } 8 | 9 | impl Yafetch { 10 | /// run yafetch with the given configuration file 11 | pub fn run(&self, path: std::path::PathBuf) { 12 | let src: String = std::fs::read_to_string(path).unwrap(); 13 | let chnk = self.lua.load(&src); 14 | match chnk.exec() { 15 | Ok(_) => {} 16 | Err(e) => println!("{}", e), 17 | } 18 | } 19 | 20 | // TODO arch 21 | 22 | fn host(&self) -> mlua::Result { 23 | let x = self 24 | .lua 25 | .create_function(|_, _: ()| Ok(modules::host::get())); 26 | Ok(x?) 27 | } 28 | 29 | fn cpu(&self) -> mlua::Result { 30 | let x = self.lua.create_function(|_, _: ()| Ok(modules::cpu::get())); 31 | Ok(x?) 32 | } 33 | 34 | fn kernel(&self) -> mlua::Result { 35 | let x = self 36 | .lua 37 | .create_function(|_, _: ()| Ok(modules::kernel::get())); 38 | Ok(x?) 39 | } 40 | 41 | fn os(&self) -> mlua::Result { 42 | let x = self.lua.create_function(|_, _: ()| Ok(modules::os::get())); 43 | Ok(x?) 44 | } 45 | 46 | fn uptime(&self) -> mlua::Result { 47 | let x = self 48 | .lua 49 | .create_function(|_, _: ()| Ok(modules::uptime::get())); 50 | Ok(x?) 51 | } 52 | 53 | fn user(&self) -> mlua::Result { 54 | let x = self 55 | .lua 56 | .create_function(|_, _: ()| Ok(modules::user::get())); 57 | Ok(x?) 58 | } 59 | 60 | fn hostname(&self) -> mlua::Result { 61 | let x = self 62 | .lua 63 | .create_function(|_, _: ()| Ok(modules::hostname::get())); 64 | Ok(x?) 65 | } 66 | 67 | fn disk_total(&self) -> mlua::Result { 68 | let x = self 69 | .lua 70 | .create_function(|_, path: String| Ok(modules::disk::get_total(path))); 71 | Ok(x?) 72 | } 73 | 74 | fn disk_free(&self) -> mlua::Result { 75 | let x = self 76 | .lua 77 | .create_function(|_, path: String| Ok(modules::disk::get_free(path))); 78 | Ok(x?) 79 | } 80 | 81 | fn mem_used(&self) -> mlua::Result { 82 | let x = self 83 | .lua 84 | .create_function(|_, _: ()| Ok(modules::mem::get_used())); 85 | Ok(x?) 86 | } 87 | 88 | fn mem_total(&self) -> mlua::Result { 89 | let x = self 90 | .lua 91 | .create_function(|_, _: ()| Ok(modules::mem::get_total())); 92 | Ok(x?) 93 | } 94 | 95 | pub fn register(&self) { 96 | let globals = self.lua.globals(); 97 | let exports = self.lua.create_table().unwrap(); 98 | 99 | // host 100 | 101 | exports 102 | .set("host", self.host().unwrap()) 103 | .expect("could not register host function"); 104 | 105 | exports 106 | .set("uptime", self.uptime().unwrap()) 107 | .expect("could not register uptime function"); 108 | 109 | exports 110 | .set("cpu", self.cpu().unwrap()) 111 | .expect("could not register cpu function"); 112 | 113 | exports 114 | .set("user", self.user().unwrap()) 115 | .expect("could not register user function"); 116 | 117 | exports 118 | .set("hostname", self.hostname().unwrap()) 119 | .expect("could not register hostname function"); 120 | 121 | exports 122 | .set("kernel", self.kernel().unwrap()) 123 | .expect("could not register kernel function"); 124 | 125 | exports 126 | .set("os", self.os().unwrap()) 127 | .expect("could not register os function"); 128 | 129 | // 130 | // mem 131 | // 132 | 133 | exports 134 | .set("mem_used", self.mem_used().unwrap()) 135 | .expect("could not register mem_used function"); 136 | 137 | exports 138 | .set("mem_total", self.mem_total().unwrap()) 139 | .expect("could not register mem_total function"); 140 | 141 | // 142 | // disk 143 | // 144 | 145 | exports 146 | .set("disk_free", self.disk_free().unwrap()) 147 | .expect("could not register disk_free function"); 148 | 149 | exports 150 | .set("disk_total", self.disk_total().unwrap()) 151 | .expect("could not register disk_total function"); 152 | 153 | globals.set("yafetch", exports).unwrap(); 154 | } 155 | } 156 | --------------------------------------------------------------------------------