summaryrefslogtreecommitdiffstats
path: root/src/modules/battery.rs
diff options
context:
space:
mode:
authorMatan Kushner <hello@matchai.me>2019-06-10 15:56:17 +0100
committerGitHub <noreply@github.com>2019-06-10 15:56:17 +0100
commit097f1b05f1d82967fe2a900ccf7ba3597c04ad77 (patch)
treee5419607802145bf2521defd9823d224f937b653 /src/modules/battery.rs
parent8239fbd12befad1126e677fa083ce73947d74d8c (diff)
Add support for prompt configuration (#62)
- Create `Config` struct that is added to `Context` when initialized - Read `~/.confg/starship.toml` during initialization (can be updated later to also look at `$XDG_CONFIG_HOME`) - `Context` now has a method for creating modules. This allows us to provide modules with a reference to the configuration specific to that module
Diffstat (limited to 'src/modules/battery.rs')
-rw-r--r--src/modules/battery.rs4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/modules/battery.rs b/src/modules/battery.rs
index f7f7a0e08..75ac1c554 100644
--- a/src/modules/battery.rs
+++ b/src/modules/battery.rs
@@ -3,7 +3,7 @@ use ansi_term::Color;
use super::{Context, Module};
/// Creates a segment for the battery percentage and charging state
-pub fn segment(_context: &Context) -> Option<Module> {
+pub fn segment<'a>(context: &'a Context) -> Option<Module<'a>> {
const BATTERY_FULL: &str = "•";
const BATTERY_CHARGING: &str = "⇡";
const BATTERY_DISCHARGING: &str = "⇣";
@@ -22,7 +22,7 @@ pub fn segment(_context: &Context) -> Option<Module> {
}
// TODO: Set style based on percentage when threshold is modifiable
- let mut module = Module::new("battery");
+ let mut module = context.new_module("battery");
module.set_style(Color::Red.bold());
module.get_prefix().set_value("");