microfetch/src/main.rs
2024-08-04 00:05:57 +03:00

70 lines
2.1 KiB
Rust

mod colors;
mod desktop;
mod release;
mod system;
mod uptime;
use color_eyre::{Report, Result};
use crate::colors::{BLUE, CYAN, RESET};
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_username_and_hostname};
use crate::uptime::get_system_uptime;
fn main() -> Result<(), Report> {
color_eyre::install()?;
let user_info = get_username_and_hostname()?;
let os_name = get_os_pretty_name()?;
let kernel_version = get_system_info()?;
let uptime = get_system_uptime()?;
let window_manager = get_desktop_info()?;
let memory_usage = get_memory_usage()?;
let storage = get_root_disk_usage()?;
print_system_info(
&user_info,
&os_name,
&kernel_version,
&uptime,
&window_manager,
&memory_usage,
&storage,
);
Ok(())
}
fn print_system_info(
user_info: &str,
os_name: &str,
kernel_version: &str,
uptime: &str,
window_manager: &str,
memory_usage: &str,
storage: &str,
) {
println!(
"
{CYAN} ▗▄ {BLUE}▗▄ ▄▖ {user_info} ~{RESET}
{CYAN} ▄▄🬸█▄▄▄{BLUE}🬸█▛ {CYAN}{CYAN}{BLUE}System{RESET}{os_name}
{BLUE} ▟▛ ▜{CYAN}▃▟🬕 {CYAN}{BLUE}Kernel{RESET}{kernel_version}
{BLUE}🬋🬋🬫█ {CYAN}█🬛🬋🬋 {CYAN}{BLUE}Uptime{RESET}{uptime}
{BLUE} 🬷▛🮃{CYAN}▙ ▟▛ {CYAN}{BLUE}WM{RESET}{window_manager}
{BLUE} 🮃 {CYAN}▟█🬴{BLUE}▀▀▀█🬴▀▀ {CYAN}󰍛 {BLUE}Memory{RESET}{memory_usage}
{CYAN} ▝▀ ▀▘ {BLUE}▀▘ {CYAN}󱥎 {BLUE}Storage (/){RESET}{storage}
",
CYAN = CYAN,
BLUE = BLUE,
RESET = RESET,
user_info = user_info,
os_name = os_name,
kernel_version = kernel_version,
uptime = uptime,
window_manager = window_manager,
memory_usage = memory_usage,
storage = storage
);
}