summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorClementTsang <cjhtsang@uwaterloo.ca>2020-08-16 03:08:09 -0400
committerClementTsang <cjhtsang@uwaterloo.ca>2020-08-16 03:08:09 -0400
commit9068108d0fe977ec6fc01dc7d8d29674a88c2f6a (patch)
tree3d19eeae8fdbb035cdc50bbdbf9e5c25189aed75 /src
parentd211c6474cfebee3b1cf7ba273e57120a1edd5b8 (diff)
bug: fix missing default battery layout during refactor
Diffstat (limited to 'src')
-rw-r--r--src/constants.rs31
-rw-r--r--src/options.rs8
2 files changed, 37 insertions, 2 deletions
diff --git a/src/constants.rs b/src/constants.rs
index b9a6533d..572a6e5b 100644
--- a/src/constants.rs
+++ b/src/constants.rs
@@ -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";
diff --git a/src/options.rs b/src/options.rs
index 81ac4c99..e9fb4a29 100644
--- a/src/options.rs
+++ b/src/options.rs
@@ -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
}
};