mirror of
https://github.com/NotAShelf/microfetch.git
synced 2024-11-27 01:06:44 +00:00
Compare commits
No commits in common. "17152f9d142ce0badde14018703bb1590e3df947" and "2ecf9303fa0e5ab5519edead04b55827a3facb27" have entirely different histories.
17152f9d14
...
2ecf9303fa
11 changed files with 32 additions and 98 deletions
5
.envrc
5
.envrc
|
@ -1,5 +0,0 @@
|
||||||
watch_file flake.nix
|
|
||||||
watch_file flake.lock
|
|
||||||
watch_dir nix
|
|
||||||
|
|
||||||
use flake
|
|
2
Cargo.lock
generated
2
Cargo.lock
generated
|
@ -105,7 +105,7 @@ checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "microfetch"
|
name = "microfetch"
|
||||||
version = "0.3.3"
|
version = "0.3.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"color-eyre",
|
"color-eyre",
|
||||||
"nix",
|
"nix",
|
||||||
|
|
11
Cargo.toml
11
Cargo.toml
|
@ -1,24 +1,15 @@
|
||||||
[package]
|
[package]
|
||||||
name = "microfetch"
|
name = "microfetch"
|
||||||
version = "0.3.3"
|
version = "0.3.2"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
nix = {version = "0.29", features = ["fs", "hostname"]}
|
nix = {version = "0.29", features = ["fs", "hostname"]}
|
||||||
color-eyre = { version = "0.6", default-features = false }
|
color-eyre = { version = "0.6", default-features = false }
|
||||||
|
|
||||||
[profile.dev]
|
|
||||||
opt-level = 3
|
|
||||||
|
|
||||||
[profile.release]
|
[profile.release]
|
||||||
strip = true
|
strip = true
|
||||||
opt-level = "z"
|
opt-level = "z"
|
||||||
lto = true
|
lto = true
|
||||||
codegen-units = 1
|
codegen-units = 1
|
||||||
panic = "abort"
|
panic = "abort"
|
||||||
|
|
||||||
[profile.profiler]
|
|
||||||
inherits = "release"
|
|
||||||
debug = true
|
|
||||||
split-debuginfo = "unpacked"
|
|
||||||
strip = "none"
|
|
||||||
|
|
49
README.md
49
README.md
|
@ -1,25 +1,11 @@
|
||||||
<div align="center">
|
# Microfetch
|
||||||
<img src="https://deps.rs/repo/github/notashelf/microfetch/status.svg" alt="https://deps.rs/repo/github/notashelf/microfetch">
|
|
||||||
<!-- <img src="https://img.shields.io/github/v/release/notashelf/microfetch?display_name=tag&color=DEA584"> -->
|
|
||||||
<img src="https://img.shields.io/github/stars/notashelf/microfetch?label=stars&color=DEA584">
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<h1 align="center">Microfetch</h1>
|
A stupidly simple fetch tool, written in Rust. Runs in a fraction of a second,
|
||||||
|
displays most nonsense people on r/unixporn care about. Aims to replace
|
||||||
|
fastfetch on my system, but probably not on yours. Though you are more than
|
||||||
|
welcome to use it on your system: it's fast.
|
||||||
|
|
||||||
Stupidly simple, laughably fast fetch tool. Written in Rust for speed and ease
|
![Demo](.github/assets/demo.png)
|
||||||
of maintainability. Runs in a _fraction of a millisecond_ and displays _most_ of
|
|
||||||
the nonsense you'd see posted on r/unixporn or other internet communities. Aims
|
|
||||||
to replace [fastfetch](https://github.com/fastfetch-cli/fastfetch) on my
|
|
||||||
personal system, but [probably not yours](#customizing). Though, you are more
|
|
||||||
than welcome to use it on your system: it's pretty [fast...](#benchmarks)
|
|
||||||
|
|
||||||
<p align="center">
|
|
||||||
<img
|
|
||||||
alt="latest demo"
|
|
||||||
src="./.github/assets/demo.png"
|
|
||||||
width="850px"
|
|
||||||
>
|
|
||||||
</p>
|
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
|
||||||
|
@ -34,7 +20,7 @@ than welcome to use it on your system: it's pretty [fast...](#benchmarks)
|
||||||
- Name
|
- Name
|
||||||
- Version
|
- Version
|
||||||
- Architecture
|
- Architecture
|
||||||
- Current shell (from $SHELL, trimmed if store path)
|
- Current shell (from $SHELL)
|
||||||
- WM/Compositor and display backend
|
- WM/Compositor and display backend
|
||||||
- Memory Usage/Total Memory
|
- Memory Usage/Total Memory
|
||||||
- Storage Usage/Total Storage (for `/` only)
|
- Storage Usage/Total Storage (for `/` only)
|
||||||
|
@ -48,16 +34,11 @@ trend seems to be < 2ms on any modern (2015 and after) CPU. Below are the
|
||||||
benchmarks with Hyperfine on my desktop system.
|
benchmarks with Hyperfine on my desktop system.
|
||||||
|
|
||||||
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|
||||||
| :----------- | ----------: | -------: | -------: | -------------: |
|
| :-------------------------- | --------: | -------: | -------: | -------: |
|
||||||
| `microfetch` | 1.3 ± 0.0 | 1.3 | 1.4 | 1.00 |
|
| `target/release/microfetch` | 1.3 ± 0.1 | 1.2 | 3.7 | 1.00 |
|
||||||
| `pfetch` | 254.2 ± 4.8 | 246.7 | 264.9 | 191.97 ± 7.10 |
|
|
||||||
| `neofetch` | 735.4 ± 9.5 | 721.1 | 752.8 | 555.48 ± 19.08 |
|
|
||||||
| `fastfetch` | 31.9 ± 0.8 | 30.8 | 33.8 | 24.08 ± 0.98 |
|
|
||||||
|
|
||||||
_As far as I'm concerned, Microfetch is faster than almost every fetch tool
|
On an average configuration, this is roughly 25 times faster than fastfetch and
|
||||||
there is. The only downside of using Rust is introducing more "bloated"
|
around 80 times faster than neofetch. Results, as stated above, may vary.
|
||||||
dependency trees and increasing build times. The latter is easily mitigated with
|
|
||||||
Nix's binary cache, though._
|
|
||||||
|
|
||||||
## Customizing
|
## Customizing
|
||||||
|
|
||||||
|
@ -83,14 +64,6 @@ general rule of thumb consider talking to me before creating a feature PR.
|
||||||
Contributions that help improve performance in specific areas of Microfetch are
|
Contributions that help improve performance in specific areas of Microfetch are
|
||||||
welcome. Though, prepare to be bombarded with questions.
|
welcome. Though, prepare to be bombarded with questions.
|
||||||
|
|
||||||
## Hacking
|
|
||||||
|
|
||||||
A Nix flake is provided. `nix develop` to get started. Direnv users may simply
|
|
||||||
run `direnv allow` to get started.
|
|
||||||
|
|
||||||
Non-nix users will need `cargo` and `gcc` installed on their system, see
|
|
||||||
`Cargo.toml` for available release profiles.
|
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
Microfetch is licensed under [GPL3](LICENSE). See the license file for details.
|
Microfetch is licensed under [GPL3](LICENSE). See the license file for details.
|
||||||
|
|
|
@ -13,9 +13,5 @@
|
||||||
packages = forEachSystem (system: {
|
packages = forEachSystem (system: {
|
||||||
default = pkgsForEach.${system}.callPackage ./nix/package.nix {};
|
default = pkgsForEach.${system}.callPackage ./nix/package.nix {};
|
||||||
});
|
});
|
||||||
|
|
||||||
devShells = forEachSystem (system: {
|
|
||||||
default = pkgsForEach.${system}.callPackage ./nix/shell.nix {};
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,21 +1,17 @@
|
||||||
{
|
{
|
||||||
lib,
|
lib,
|
||||||
rustPlatform,
|
rustPlatform,
|
||||||
stdenvAdapters,
|
|
||||||
llvm,
|
|
||||||
}: let
|
}: let
|
||||||
toml = (lib.importTOML ../Cargo.toml).package;
|
toml = (lib.importTOML ../Cargo.toml).package;
|
||||||
pname = toml.name;
|
pname = toml.name;
|
||||||
inherit (toml) version;
|
inherit (toml) version;
|
||||||
in
|
in
|
||||||
rustPlatform.buildRustPackage.override {stdenv = stdenvAdapters.useMoldLinker llvm.stdenv;} {
|
rustPlatform.buildRustPackage {
|
||||||
RUSTFLAGS = "-C link-arg=-fuse-ld=mold";
|
|
||||||
|
|
||||||
inherit pname version;
|
inherit pname version;
|
||||||
|
|
||||||
src = builtins.path {
|
src = builtins.path {
|
||||||
name = "${pname}-${version}";
|
name = "${pname}-${version}";
|
||||||
path = lib.sources.cleanSource ../.;
|
path = ../.;
|
||||||
};
|
};
|
||||||
|
|
||||||
cargoLock.lockFile = ../Cargo.lock;
|
cargoLock.lockFile = ../Cargo.lock;
|
||||||
|
|
|
@ -1,25 +0,0 @@
|
||||||
{
|
|
||||||
mkShell,
|
|
||||||
rust-analyzer-unwrapped,
|
|
||||||
rustfmt,
|
|
||||||
clippy,
|
|
||||||
cargo,
|
|
||||||
rustc,
|
|
||||||
gcc,
|
|
||||||
rustPlatform,
|
|
||||||
}:
|
|
||||||
mkShell {
|
|
||||||
strictDeps = true;
|
|
||||||
|
|
||||||
nativeBuildInputs = [
|
|
||||||
cargo
|
|
||||||
rustc
|
|
||||||
gcc
|
|
||||||
|
|
||||||
rust-analyzer-unwrapped
|
|
||||||
rustfmt
|
|
||||||
clippy
|
|
||||||
];
|
|
||||||
|
|
||||||
env.RUST_SRC_PATH = "${rustPlatform.rustLibSrc}";
|
|
||||||
}
|
|
|
@ -1,4 +1,3 @@
|
||||||
use color_eyre::Result;
|
|
||||||
use std::{env, io};
|
use std::{env, io};
|
||||||
|
|
||||||
pub fn get_desktop_info() -> Result<String, io::Error> {
|
pub fn get_desktop_info() -> Result<String, io::Error> {
|
||||||
|
|
|
@ -9,7 +9,6 @@ use crate::desktop::get_desktop_info;
|
||||||
use crate::release::{get_os_pretty_name, get_system_info};
|
use crate::release::{get_os_pretty_name, get_system_info};
|
||||||
use crate::system::{get_memory_usage, get_root_disk_usage, get_shell, get_username_and_hostname};
|
use crate::system::{get_memory_usage, get_root_disk_usage, get_shell, get_username_and_hostname};
|
||||||
use crate::uptime::get_current;
|
use crate::uptime::get_current;
|
||||||
|
|
||||||
use color_eyre::Report;
|
use color_eyre::Report;
|
||||||
use nix::sys::sysinfo::sysinfo;
|
use nix::sys::sysinfo::sysinfo;
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
use color_eyre::Result;
|
|
||||||
use nix::sys::statvfs::statvfs;
|
use nix::sys::statvfs::statvfs;
|
||||||
use nix::sys::sysinfo::SysInfo;
|
use nix::sys::sysinfo::SysInfo;
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,21 @@
|
||||||
use color_eyre::Result;
|
use std::fs::File;
|
||||||
use nix::sys::sysinfo::sysinfo;
|
use std::io::{self, BufRead, BufReader};
|
||||||
use std::io;
|
use std::path::Path;
|
||||||
|
|
||||||
pub fn get_current() -> Result<String, io::Error> {
|
pub fn get_current() -> Result<String, io::Error> {
|
||||||
let info = sysinfo().map_err(|e| io::Error::new(io::ErrorKind::Other, e))?;
|
let path = Path::new("/proc/uptime");
|
||||||
let uptime_seconds = info.uptime().as_secs_f64();
|
let file = File::open(path)?;
|
||||||
|
let mut reader = BufReader::new(file);
|
||||||
|
|
||||||
|
let mut line = String::new();
|
||||||
|
reader.read_line(&mut line)?;
|
||||||
|
|
||||||
|
let uptime_seconds: f64 = line
|
||||||
|
.split_whitespace()
|
||||||
|
.next()
|
||||||
|
.ok_or_else(|| io::Error::new(io::ErrorKind::Other, "Failed to parse uptime"))?
|
||||||
|
.parse()
|
||||||
|
.map_err(|e| io::Error::new(io::ErrorKind::InvalidData, e))?;
|
||||||
|
|
||||||
let total_minutes = (uptime_seconds / 60.0).round() as u64;
|
let total_minutes = (uptime_seconds / 60.0).round() as u64;
|
||||||
let days = total_minutes / (60 * 24);
|
let days = total_minutes / (60 * 24);
|
||||||
|
|
Loading…
Reference in a new issue