mirror of
https://github.com/Zedfrigg/ironbar.git
synced 2025-07-01 10:41:03 +02:00
refactor(sys_info): use snake_case for module tokens for consistency
BREAKING CHANGE: This renames the module from `sys-info` to `sys_info`, and almost every formatting token from `kebab-case` to `snake_case`. Any use of this module will need to be updated.
This commit is contained in:
parent
0fb5fa8c2a
commit
df77020c52
3 changed files with 71 additions and 71 deletions
|
@ -293,19 +293,19 @@ fn refresh_memory_tokens(format_info: &mut HashMap<String, String>, sys: &mut Sy
|
|||
let memory_percent = actual_used_memory as f64 / total_memory as f64 * 100.0;
|
||||
|
||||
format_info.insert(
|
||||
String::from("memory-free"),
|
||||
String::from("memory_free"),
|
||||
(bytes_to_gigabytes(available_memory)).to_string(),
|
||||
);
|
||||
format_info.insert(
|
||||
String::from("memory-used"),
|
||||
String::from("memory_used"),
|
||||
(bytes_to_gigabytes(actual_used_memory)).to_string(),
|
||||
);
|
||||
format_info.insert(
|
||||
String::from("memory-total"),
|
||||
String::from("memory_total"),
|
||||
(bytes_to_gigabytes(total_memory)).to_string(),
|
||||
);
|
||||
format_info.insert(
|
||||
String::from("memory-percent"),
|
||||
String::from("memory_percent"),
|
||||
format!("{:0>2.0}", memory_percent),
|
||||
);
|
||||
|
||||
|
@ -313,19 +313,19 @@ fn refresh_memory_tokens(format_info: &mut HashMap<String, String>, sys: &mut Sy
|
|||
let total_swap = sys.total_swap();
|
||||
|
||||
format_info.insert(
|
||||
String::from("swap-free"),
|
||||
String::from("swap_free"),
|
||||
(bytes_to_gigabytes(sys.free_swap())).to_string(),
|
||||
);
|
||||
format_info.insert(
|
||||
String::from("swap-used"),
|
||||
String::from("swap_used"),
|
||||
(bytes_to_gigabytes(used_swap)).to_string(),
|
||||
);
|
||||
format_info.insert(
|
||||
String::from("swap-total"),
|
||||
String::from("swap_total"),
|
||||
(bytes_to_gigabytes(total_swap)).to_string(),
|
||||
);
|
||||
format_info.insert(
|
||||
String::from("swap-percent"),
|
||||
String::from("swap_percent"),
|
||||
format!("{:0>2.0}", used_swap as f64 / total_swap as f64 * 100.0),
|
||||
);
|
||||
}
|
||||
|
@ -337,7 +337,7 @@ fn refresh_cpu_tokens(format_info: &mut HashMap<String, String>, sys: &mut Syste
|
|||
let cpu_percent = cpu_info.cpu_usage();
|
||||
|
||||
format_info.insert(
|
||||
String::from("cpu-percent"),
|
||||
String::from("cpu_percent"),
|
||||
format!("{:0>2.0}", cpu_percent),
|
||||
);
|
||||
}
|
||||
|
@ -350,8 +350,8 @@ fn refresh_temp_tokens(format_info: &mut HashMap<String, String>, sys: &mut Syst
|
|||
let key = component.label().replace(' ', "-");
|
||||
let temp = component.temperature();
|
||||
|
||||
format_info.insert(format!("temp-c:{key}"), format!("{temp:.0}"));
|
||||
format_info.insert(format!("temp-f:{key}"), format!("{:.0}", c_to_f(temp)));
|
||||
format_info.insert(format!("temp_c:{key}"), format!("{temp:.0}"));
|
||||
format_info.insert(format!("temp_f:{key}"), format!("{:.0}", c_to_f(temp)));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -371,22 +371,22 @@ fn refresh_disk_tokens(format_info: &mut HashMap<String, String>, sys: &mut Syst
|
|||
let used = total - available;
|
||||
|
||||
format_info.insert(
|
||||
format!("disk-free:{key}"),
|
||||
format!("disk_free:{key}"),
|
||||
bytes_to_gigabytes(available).to_string(),
|
||||
);
|
||||
|
||||
format_info.insert(
|
||||
format!("disk-used:{key}"),
|
||||
format!("disk_used:{key}"),
|
||||
bytes_to_gigabytes(used).to_string(),
|
||||
);
|
||||
|
||||
format_info.insert(
|
||||
format!("disk-total:{key}"),
|
||||
format!("disk_total:{key}"),
|
||||
bytes_to_gigabytes(total).to_string(),
|
||||
);
|
||||
|
||||
format_info.insert(
|
||||
format!("disk-percent:{key}"),
|
||||
format!("disk_percent:{key}"),
|
||||
format!("{:0>2.0}", used as f64 / total as f64 * 100.0),
|
||||
);
|
||||
}
|
||||
|
@ -402,12 +402,12 @@ fn refresh_network_tokens(
|
|||
|
||||
for (iface, network) in sys.networks() {
|
||||
format_info.insert(
|
||||
format!("net-down:{iface}"),
|
||||
format!("net_down:{iface}"),
|
||||
format!("{:0>2.0}", bytes_to_megabits(network.received()) / interval),
|
||||
);
|
||||
|
||||
format_info.insert(
|
||||
format!("net-up:{iface}"),
|
||||
format!("net_up:{iface}"),
|
||||
format!(
|
||||
"{:0>2.0}",
|
||||
bytes_to_megabits(network.transmitted()) / interval
|
||||
|
@ -420,15 +420,15 @@ fn refresh_system_tokens(format_info: &mut HashMap<String, String>, sys: &System
|
|||
// no refresh required for these tokens
|
||||
|
||||
let load_average = sys.load_average();
|
||||
format_info.insert(String::from("load-average:1"), load_average.one.to_string());
|
||||
format_info.insert(String::from("load_average:1"), load_average.one.to_string());
|
||||
|
||||
format_info.insert(
|
||||
String::from("load-average:5"),
|
||||
String::from("load_average:5"),
|
||||
load_average.five.to_string(),
|
||||
);
|
||||
|
||||
format_info.insert(
|
||||
String::from("load-average:15"),
|
||||
String::from("load_average:15"),
|
||||
load_average.fifteen.to_string(),
|
||||
);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue