bug: fix missing default battery layout during refactor

This commit is contained in:
ClementTsang 2020-08-16 03:08:09 -04:00
parent d211c6474c
commit 9068108d0f
2 changed files with 37 additions and 2 deletions

View File

@ -178,7 +178,7 @@ lazy_static! {
];
}
// Default layout
// Default layouts
pub const DEFAULT_LAYOUT: &str = r##"
[[row]]
ratio=30
@ -204,6 +204,35 @@ pub const DEFAULT_LAYOUT: &str = r##"
default=true
"##;
pub const DEFAULT_BATTERY_LAYOUT: &str = r##"
[[row]]
ratio=30
[[row.child]]
ratio=2
type="cpu"
[[row.child]]
ratio=1
type="battery"
[[row]]
ratio=40
[[row.child]]
ratio=4
type="mem"
[[row.child]]
ratio=3
[[row.child.child]]
type="temp"
[[row.child.child]]
type="disk"
[[row]]
ratio=30
[[row.child]]
type="net"
[[row.child]]
type="proc"
default=true
"##;
// Config and flags
pub const DEFAULT_CONFIG_FILE_PATH: &str = "bottom/bottom.toml";

View File

@ -267,7 +267,13 @@ pub fn get_widget_layout(
Some(r) => r,
None => {
// This cannot (like it really shouldn't) fail!
ref_row = toml::from_str::<Config>(DEFAULT_LAYOUT)?.row.unwrap();
ref_row = toml::from_str::<Config>(if get_use_battery(matches, config) {
DEFAULT_BATTERY_LAYOUT
} else {
DEFAULT_LAYOUT
})?
.row
.unwrap();
&ref_row
}
};