mirror of
https://github.com/NotAShelf/microfetch.git
synced 2025-11-26 01:02:50 +00:00
microfetch: trim fetch screen by one space
Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: I200c72b5a8249ed3d23754aa3f01aea86a6a6964
This commit is contained in:
parent
dab8f556af
commit
1d69d3107c
1 changed files with 70 additions and 60 deletions
130
src/main.rs
130
src/main.rs
|
|
@ -4,78 +4,88 @@ mod release;
|
||||||
mod system;
|
mod system;
|
||||||
mod uptime;
|
mod uptime;
|
||||||
|
|
||||||
use crate::colors::print_dots;
|
|
||||||
use crate::desktop::get_desktop_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::uptime::get_current;
|
|
||||||
use std::io::{Write, stdout};
|
use std::io::{Write, stdout};
|
||||||
|
|
||||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
use crate::{
|
||||||
if Some("--version") == std::env::args().nth(1).as_deref() {
|
colors::print_dots,
|
||||||
println!("Microfetch {}", env!("CARGO_PKG_VERSION"));
|
desktop::get_desktop_info,
|
||||||
} else {
|
release::{get_os_pretty_name, get_system_info},
|
||||||
let utsname = nix::sys::utsname::uname()?;
|
system::{
|
||||||
let fields = Fields {
|
get_memory_usage,
|
||||||
user_info: get_username_and_hostname(&utsname),
|
get_root_disk_usage,
|
||||||
os_name: get_os_pretty_name()?,
|
get_shell,
|
||||||
kernel_version: get_system_info(&utsname),
|
get_username_and_hostname,
|
||||||
shell: get_shell(),
|
},
|
||||||
desktop: get_desktop_info(),
|
uptime::get_current,
|
||||||
uptime: get_current()?,
|
};
|
||||||
memory_usage: get_memory_usage()?,
|
|
||||||
storage: get_root_disk_usage()?,
|
|
||||||
colors: print_dots(),
|
|
||||||
};
|
|
||||||
print_system_info(&fields)?;
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(())
|
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
|
if Some("--version") == std::env::args().nth(1).as_deref() {
|
||||||
|
println!("Microfetch {}", env!("CARGO_PKG_VERSION"));
|
||||||
|
} else {
|
||||||
|
let utsname = nix::sys::utsname::uname()?;
|
||||||
|
let fields = Fields {
|
||||||
|
user_info: get_username_and_hostname(&utsname),
|
||||||
|
os_name: get_os_pretty_name()?,
|
||||||
|
kernel_version: get_system_info(&utsname),
|
||||||
|
shell: get_shell(),
|
||||||
|
desktop: get_desktop_info(),
|
||||||
|
uptime: get_current()?,
|
||||||
|
memory_usage: get_memory_usage()?,
|
||||||
|
storage: get_root_disk_usage()?,
|
||||||
|
colors: print_dots(),
|
||||||
|
};
|
||||||
|
print_system_info(&fields)?;
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
// Struct to hold all the fields we need in order to print the fetch. This
|
// Struct to hold all the fields we need in order to print the fetch. This
|
||||||
// helps avoid Clippy warnings about argument count, and makes it slightly
|
// helps avoid Clippy warnings about argument count, and makes it slightly
|
||||||
// easier to pass data around. Though, it is not like we really need to.
|
// easier to pass data around. Though, it is not like we really need to.
|
||||||
struct Fields {
|
struct Fields {
|
||||||
user_info: String,
|
user_info: String,
|
||||||
os_name: String,
|
os_name: String,
|
||||||
kernel_version: String,
|
kernel_version: String,
|
||||||
shell: String,
|
shell: String,
|
||||||
uptime: String,
|
uptime: String,
|
||||||
desktop: String,
|
desktop: String,
|
||||||
memory_usage: String,
|
memory_usage: String,
|
||||||
storage: String,
|
storage: String,
|
||||||
colors: String,
|
colors: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn print_system_info(fields: &Fields) -> Result<(), Box<dyn std::error::Error>> {
|
fn print_system_info(
|
||||||
use crate::colors::COLORS;
|
fields: &Fields,
|
||||||
|
) -> Result<(), Box<dyn std::error::Error>> {
|
||||||
|
use crate::colors::COLORS;
|
||||||
|
|
||||||
let Fields {
|
let Fields {
|
||||||
user_info,
|
user_info,
|
||||||
os_name,
|
os_name,
|
||||||
kernel_version,
|
kernel_version,
|
||||||
shell,
|
shell,
|
||||||
uptime,
|
uptime,
|
||||||
desktop,
|
desktop,
|
||||||
memory_usage,
|
memory_usage,
|
||||||
storage,
|
storage,
|
||||||
colors,
|
colors,
|
||||||
} = fields;
|
} = fields;
|
||||||
|
|
||||||
let cyan = COLORS.cyan;
|
let cyan = COLORS.cyan;
|
||||||
let blue = COLORS.blue;
|
let blue = COLORS.blue;
|
||||||
let reset = COLORS.reset;
|
let reset = COLORS.reset;
|
||||||
let system_info = format!("
|
let system_info = format!("
|
||||||
{cyan} ▟█▖ {blue}▝█▙ ▗█▛ {user_info} ~{reset}
|
{cyan} ▟█▖ {blue}▝█▙ ▗█▛ {user_info} ~{reset}
|
||||||
{cyan} ▗▄▄▟██▄▄▄▄▄{blue}▝█▙█▛ {cyan}▖ {cyan} {blue}System{reset} {os_name}
|
{cyan} ▗▄▄▟██▄▄▄▄▄{blue}▝█▙█▛ {cyan}▖ {cyan} {blue}System{reset} {os_name}
|
||||||
{cyan} ▀▀▀▀▀▀▀▀▀▀▀▘{blue}▝██ {cyan}▟█▖ {cyan} {blue}Kernel{reset} {kernel_version}
|
{cyan} ▀▀▀▀▀▀▀▀▀▀▀▘{blue}▝██ {cyan}▟█▖ {cyan} {blue}Kernel{reset} {kernel_version}
|
||||||
{blue} ▟█▛ {blue}▝█▘{cyan}▟█▛ {cyan} {blue}Shell{reset} {shell}
|
{blue} ▟█▛ {blue}▝█▘{cyan}▟█▛ {cyan} {blue}Shell{reset} {shell}
|
||||||
{blue}▟█████▛ {cyan}▟█████▛ {cyan} {blue}Uptime{reset} {uptime}
|
{blue}▟█████▛ {cyan}▟█████▛ {cyan} {blue}Uptime{reset} {uptime}
|
||||||
{blue} ▟█▛{cyan}▗█▖ {cyan}▟█▛ {cyan} {blue}Desktop{reset} {desktop}
|
{blue} ▟█▛{cyan}▗█▖ {cyan}▟█▛ {cyan} {blue}Desktop{reset} {desktop}
|
||||||
{blue} ▝█▛ {cyan}██▖{blue}▗▄▄▄▄▄▄▄▄▄▄▄ {cyan} {blue}Memory{reset} {memory_usage}
|
{blue} ▝█▛ {cyan}██▖{blue}▗▄▄▄▄▄▄▄▄▄▄▄ {cyan} {blue}Memory{reset} {memory_usage}
|
||||||
{blue} ▝ {cyan}▟█▜█▖{blue}▀▀▀▀▀██▛▀▀▘ {cyan} {blue}Storage (/){reset} {storage}
|
{blue} ▝ {cyan}▟█▜█▖{blue}▀▀▀▀▀██▛▀▀▘ {cyan} {blue}Storage (/){reset} {storage}
|
||||||
{cyan} ▟█▘ ▜█▖ {blue}▝█▛ {cyan} {blue}Colors{reset} {colors}\n");
|
{cyan} ▟█▘ ▜█▖ {blue}▝█▛ {cyan} {blue}Colors{reset} {colors}\n");
|
||||||
|
|
||||||
Ok(stdout().write_all(system_info.as_bytes())?)
|
Ok(stdout().write_all(system_info.as_bytes())?)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue