Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pub fn config_dir() -> Result<String, VarError> {
pub fn init_config() -> Result<bool, Box<dyn Error>> {
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)?;
Expand Down
20 changes: 12 additions & 8 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,31 +19,35 @@ fn main() -> Result<(), Box<dyn Error>> {

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
);
}

Expand Down