2024-08-03 17:42:48 +00:00
|
|
|
mod colors;
|
|
|
|
mod desktop;
|
|
|
|
mod release;
|
|
|
|
mod system;
|
|
|
|
mod uptime;
|
|
|
|
|
2024-08-04 10:07:27 +00:00
|
|
|
use crate::colors::{print_dots, BLUE, CYAN, RESET};
|
2024-08-03 17:42:48 +00:00
|
|
|
use crate::desktop::get_desktop_info;
|
|
|
|
use crate::release::{get_os_pretty_name, get_system_info};
|
2024-08-04 10:07:27 +00:00
|
|
|
use crate::system::{get_memory_usage, get_root_disk_usage, get_shell, get_username_and_hostname};
|
2024-08-03 21:07:11 +00:00
|
|
|
use crate::uptime::get_current;
|
2024-08-04 22:37:32 +00:00
|
|
|
|
2024-08-04 10:07:27 +00:00
|
|
|
use color_eyre::Report;
|
|
|
|
use nix::sys::sysinfo::sysinfo;
|
2024-08-03 16:06:29 +00:00
|
|
|
|
2024-08-03 17:00:58 +00:00
|
|
|
fn main() -> Result<(), Report> {
|
|
|
|
color_eyre::install()?;
|
|
|
|
|
2024-08-05 08:33:42 +00:00
|
|
|
let fields = Fields {
|
2024-08-13 20:59:11 +00:00
|
|
|
user_info: get_username_and_hostname(),
|
2024-08-05 08:33:42 +00:00
|
|
|
os_name: get_os_pretty_name()?,
|
|
|
|
kernel_version: get_system_info()?,
|
2024-08-13 20:59:11 +00:00
|
|
|
shell: get_shell(),
|
2024-08-05 08:33:42 +00:00
|
|
|
uptime: get_current()?,
|
2024-08-13 20:59:11 +00:00
|
|
|
window_manager: get_desktop_info(),
|
2024-08-05 08:33:42 +00:00
|
|
|
memory_usage: get_memory_usage(sysinfo()?),
|
|
|
|
storage: get_root_disk_usage()?,
|
2024-08-13 20:59:11 +00:00
|
|
|
colors: print_dots(),
|
2024-08-05 08:33:42 +00:00
|
|
|
};
|
2024-08-03 16:06:29 +00:00
|
|
|
|
2024-08-05 08:33:42 +00:00
|
|
|
print_system_info(&fields);
|
2024-08-04 10:07:27 +00:00
|
|
|
|
|
|
|
Ok(())
|
2024-08-03 21:05:57 +00:00
|
|
|
}
|
2024-08-03 17:00:58 +00:00
|
|
|
|
2024-08-05 08:33:42 +00:00
|
|
|
// Struct to hold all the fields we need to print
|
|
|
|
// helps avoid clippy warnings about argument count
|
|
|
|
// and makes it easier to pass around, though its
|
|
|
|
// not like we need to
|
|
|
|
struct Fields {
|
|
|
|
user_info: String,
|
|
|
|
os_name: String,
|
|
|
|
kernel_version: String,
|
|
|
|
shell: String,
|
|
|
|
uptime: String,
|
|
|
|
window_manager: String,
|
|
|
|
memory_usage: String,
|
|
|
|
storage: String,
|
|
|
|
colors: String,
|
|
|
|
}
|
|
|
|
|
|
|
|
fn print_system_info(fields: &Fields) {
|
2024-08-13 20:59:11 +00:00
|
|
|
let Fields {
|
|
|
|
user_info,
|
|
|
|
os_name,
|
|
|
|
kernel_version,
|
|
|
|
shell,
|
|
|
|
uptime,
|
|
|
|
window_manager,
|
|
|
|
memory_usage,
|
|
|
|
storage,
|
|
|
|
colors,
|
|
|
|
} = fields;
|
|
|
|
|
2024-08-03 17:00:58 +00:00
|
|
|
println!(
|
2024-08-03 16:06:29 +00:00
|
|
|
"
|
2024-08-04 09:42:53 +00:00
|
|
|
{CYAN} ▟█▖ {BLUE}▝█▙ ▗█▛ {user_info} ~{RESET}
|
|
|
|
{CYAN} ▗▄▄▟██▄▄▄▄▄{BLUE}▝█▙█▛ {CYAN}▖ {CYAN} {BLUE}System{RESET} {os_name}
|
|
|
|
{CYAN} ▀▀▀▀▀▀▀▀▀▀▀▘{BLUE}▝██ {CYAN}▟█▖ {CYAN} {BLUE}Kernel{RESET} {kernel_version}
|
2024-08-04 10:07:27 +00:00
|
|
|
{BLUE} ▟█▛ {BLUE}▝█▘{CYAN}▟█▛ {CYAN} {BLUE}Shell{RESET} {shell}
|
|
|
|
{BLUE}▟█████▛ {CYAN}▟█████▛ {CYAN} {BLUE}Uptime{RESET} {uptime}
|
|
|
|
{BLUE} ▟█▛{CYAN}▗█▖ {CYAN}▟█▛ {CYAN} {BLUE}WM{RESET} {window_manager}
|
|
|
|
{BLUE} ▝█▛ {CYAN}██▖{BLUE}▗▄▄▄▄▄▄▄▄▄▄▄ {CYAN} {BLUE}Memory{RESET} {memory_usage}
|
|
|
|
{BLUE} ▝ {CYAN}▟█▜█▖{BLUE}▀▀▀▀▀██▛▀▀▘ {CYAN} {BLUE}Storage (/){RESET} {storage}
|
2024-08-13 20:59:11 +00:00
|
|
|
{CYAN} ▟█▘ ▜█▖ {BLUE}▝█▛ {CYAN} {BLUE}Colors{RESET} {colors}");
|
2024-08-03 16:06:29 +00:00
|
|
|
}
|