mirror of
https://github.com/Wojtek242/rwmstatus.git
synced 2024-11-21 07:15:24 +01:00
Add changelog and minor doc fixes in preparation for v1.0.0
This commit is contained in:
parent
bd8df56616
commit
a6d36906a8
9
CHANGELOG.md
Normal file
9
CHANGELOG.md
Normal file
@ -0,0 +1,9 @@
|
||||
# v1.0.0
|
||||
|
||||
* Improved error handling - use `Result`, `StatusError`, and `Option` instead of empty strings
|
||||
* Applied changes based on code review in [this Reddit comment](https://www.reddit.com/r/rust/comments/aanedt/porting_c_code_to_rust_notes_questions_and/ecuatbf/)
|
||||
* Applied changes based on code review in [#1](https://github.com/Wojtek242/rwmstatus/issues/1)
|
||||
|
||||
# v0.1.0
|
||||
|
||||
* Port of [dwmstatus](https://git.suckless.org/dwmstatus/file/dwmstatus.c.html) as it was on 2018-12-25
|
@ -1,9 +1,9 @@
|
||||
[package]
|
||||
name = "rwmstatus"
|
||||
version = "0.1.0"
|
||||
version = "1.0.0"
|
||||
authors = ["Wojciech Kozlowski <wk@wojciechkozlowski.eu>"]
|
||||
license = "AGPL-3.0"
|
||||
keywords = ["wm", "status", "monitor"]
|
||||
keywords = ["monitor", "status", "window", "wm", "x11"]
|
||||
readme = "README.md"
|
||||
repository = "https://github.com/Wojtek242/rwmstatus"
|
||||
homepage = "https://github.com/Wojtek242/rwmstatus"
|
||||
|
@ -44,7 +44,7 @@ pub fn get_batt(batt: &PathBuf) -> Result<String, StatusError> {
|
||||
return Err(StatusError::NotPresent(batt.to_str().unwrap().to_string()));
|
||||
}
|
||||
|
||||
let desired_capacity: u64 = read_to_string(batt.join("charge_full_design"))
|
||||
let design_capacity: u64 = read_to_string(batt.join("charge_full_design"))
|
||||
.or_else(|_| read_to_string(batt.join("energy_full_design")))?
|
||||
.trim()
|
||||
.parse()?;
|
||||
@ -66,11 +66,11 @@ pub fn get_batt(batt: &PathBuf) -> Result<String, StatusError> {
|
||||
Err(_) => '?',
|
||||
};
|
||||
|
||||
let percentage = ((remaining_capacity as f64) / (desired_capacity as f64)) * 100.0;
|
||||
let percentage = ((remaining_capacity as f64) / (design_capacity as f64)) * 100.0;
|
||||
Ok(format!("{:.0}%{}", percentage, status))
|
||||
}
|
||||
|
||||
/// Get the time for the provided time zone.
|
||||
/// Get the time for the provided timezone in the provided format.
|
||||
pub fn get_tz_time(tz_name: &str, fmt: &str) -> Result<String, StatusError> {
|
||||
let tz: chrono_tz::Tz = tz_name.parse().map_err(StatusError::ParseTz)?;
|
||||
let utc = Utc::now().naive_utc();
|
||||
|
Loading…
Reference in New Issue
Block a user