From 9d02a196c5d3af3107d85759a7e365ef921f388c Mon Sep 17 00:00:00 2001 From: April Date: Thu, 23 Oct 2025 23:03:51 +0100 Subject: [PATCH 1/3] add profile for release in manifest --- Cargo.toml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index 2f21ac6..7768c34 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,3 +10,9 @@ license = "MIT" [dependencies] serde = { version = "1.0.228", features = ["derive"] } toml = "0.9.8" + +[profile.release] +strip = true +lto = true +opt-level = 3 +codegen-units = 1 \ No newline at end of file From 4842f98e2b4c59d87148fd0f7af30f1823f50c16 Mon Sep 17 00:00:00 2001 From: April Date: Thu, 23 Oct 2025 23:07:53 +0100 Subject: [PATCH 2/3] fix panics --- src/config/mod.rs | 2 +- src/main.rs | 22 +++++++++++++--------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/config/mod.rs b/src/config/mod.rs index 825e28f..2875279 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -21,7 +21,7 @@ pub fn config_dir() -> Result { pub fn init_config() -> Result> { let dir = config_dir()?; if !fs::exists(&dir)? { - fs::create_dir(&dir)?; + fs::create_dir_all(&dir)?; let file = format!("{}/config.toml", dir); let cfg = config::default(); let contents = toml::to_string(&cfg)?; diff --git a/src/main.rs b/src/main.rs index febb1ea..0d96c3d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -19,33 +19,37 @@ fn main() -> Result<(), Box> { let ascii_art = match cfg.display.ascii.as_str() { "stack" => ascii::STACK, - s => panic!("unknown ascii art '{}'", s), + s => return Err(format!("unknown ascii art '{}'", s).into()), }; let max_length = ascii_art .lines() .max_by_key(|l| l.chars().count()) - .unwrap() - .chars() - .count(); + .map(|l| l.chars().count()) + .unwrap_or(0); for line in ascii_art.lines() { let module_name = modules.pop_front().unwrap_or(""); - let out: (&str, String) = match module_name { + + if module_name.is_empty() { + println!("{line:max_length$}"); + continue; + } + + let (key, value) = match module_name { "os" => ("OS", data::os::distro()), "desktop" => ("DE", data::desktop::desktop()), "shell" => ("SH", data::shell::shell()), "uptime" => ("UP", data::uptime::uptime()), - _ => panic!("unknown module '{}'", module_name), + _ => return Err(format!("unknown module '{}'", module_name).into()), }; + println!( "{line:max_length$} {accent}{key}{primary}{seperator}{value}{RESET}", accent = cfg.colours.accent, - key = out.0, primary = cfg.colours.primary, seperator = cfg.display.seperator, - value = out.1 ); } Ok(()) -} +} \ No newline at end of file From 1c3e7ea26565158b99260d4f5162836335a83714 Mon Sep 17 00:00:00 2001 From: April Date: Thu, 23 Oct 2025 23:10:33 +0100 Subject: [PATCH 3/3] =?UTF-8?q?forgor=20to=20format=20=E2=98=A0=EF=B8=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main.rs b/src/main.rs index 0d96c3d..4f9d2bd 100644 --- a/src/main.rs +++ b/src/main.rs @@ -29,12 +29,12 @@ fn main() -> Result<(), Box> { for line in ascii_art.lines() { let module_name = modules.pop_front().unwrap_or(""); - + if module_name.is_empty() { println!("{line:max_length$}"); continue; } - + let (key, value) = match module_name { "os" => ("OS", data::os::distro()), "desktop" => ("DE", data::desktop::desktop()), @@ -42,7 +42,7 @@ fn main() -> Result<(), Box> { "uptime" => ("UP", data::uptime::uptime()), _ => return Err(format!("unknown module '{}'", module_name).into()), }; - + println!( "{line:max_length$} {accent}{key}{primary}{seperator}{value}{RESET}", accent = cfg.colours.accent, @@ -52,4 +52,4 @@ fn main() -> Result<(), Box> { } Ok(()) -} \ No newline at end of file +}