Delete unneeded name() method from BarModuleFn trait

main
Tassilo Horn 3 years ago
parent 726d9a0a9e
commit 7035268413
  1. 3
      swayrbar/src/bar/module.rs
  2. 8
      swayrbar/src/bar/module/battery.rs
  3. 6
      swayrbar/src/bar/module/date.rs
  4. 6
      swayrbar/src/bar/module/sysinfo.rs
  5. 10
      swayrbar/src/bar/module/window.rs

@ -28,9 +28,6 @@ pub trait BarModuleFn: Sync + Send {
where
Self: Sized;
fn default_config(instance: String) -> config::ModuleConfig
where
Self: Sized;
fn name() -> &'static str
where
Self: Sized;
fn get_config(&self) -> &config::ModuleConfig;

@ -96,7 +96,7 @@ impl BarModuleFn for BarModuleBattery {
fn default_config(instance: String) -> config::ModuleConfig {
config::ModuleConfig {
name: Self::name().to_owned(),
name: NAME.to_owned(),
instance,
format: "🔋 Bat: {state_of_charge:{:5.1}}%, {state}, Health: {state_of_health:{:5.1}}%".to_owned(),
html_escape: true,
@ -104,10 +104,6 @@ impl BarModuleFn for BarModuleBattery {
}
}
fn name() -> &'static str {
NAME
}
fn get_config(&self) -> &config::ModuleConfig {
&self.config
}
@ -115,7 +111,7 @@ impl BarModuleFn for BarModuleBattery {
fn build(&self) -> s::Block {
let text = get_text(&self.config);
s::Block {
name: Some(Self::name().to_owned()),
name: Some(NAME.to_owned()),
instance: Some(self.config.instance.clone()),
full_text: text,
align: Some(s::Align::Right),

@ -46,10 +46,6 @@ impl BarModuleFn for BarModuleDate {
}
}
fn name() -> &'static str {
NAME
}
fn get_config(&self) -> &config::ModuleConfig {
&self.config
}
@ -57,7 +53,7 @@ impl BarModuleFn for BarModuleDate {
fn build(&self) -> s::Block {
let text = chrono::Local::now().format(&self.config.format).to_string();
s::Block {
name: Some(Self::name().to_owned()),
name: Some(NAME.to_owned()),
instance: Some(self.config.instance.clone()),
full_text: text,
align: Some(s::Align::Right),

@ -104,10 +104,6 @@ impl BarModuleFn for BarModuleSysInfo {
}
}
fn name() -> &'static str {
NAME
}
fn get_config(&self) -> &config::ModuleConfig {
&self.config
}
@ -115,7 +111,7 @@ impl BarModuleFn for BarModuleSysInfo {
fn build(&self) -> s::Block {
let updater = OnceRefresher::new();
s::Block {
name: Some(Self::name().to_owned()),
name: Some(NAME.to_owned()),
instance: Some(self.config.instance.clone()),
full_text: {
let mut sys = self.system.lock().unwrap();

@ -37,7 +37,7 @@ impl BarModuleFn for BarModuleWindow {
fn default_config(instance: String) -> config::ModuleConfig {
config::ModuleConfig {
name: Self::name().to_owned(),
name: NAME.to_owned(),
instance,
format: "🪟 {title} — {app_name}".to_owned(),
html_escape: true,
@ -45,10 +45,6 @@ impl BarModuleFn for BarModuleWindow {
}
}
fn name() -> &'static str {
NAME
}
fn get_config(&self) -> &config::ModuleConfig {
&self.config
}
@ -61,14 +57,14 @@ impl BarModuleFn for BarModuleWindow {
let text = match focused_win {
Some(win) => {
fmt_replace!(&self.config.format, self.config.html_escape, {
"title" |"name" => win.get_name(),
"title" | "name" => win.get_name(),
"app_name" => win.get_app_name(),
})
}
None => String::new(),
};
s::Block {
name: Some(Self::name().to_owned()),
name: Some(NAME.to_owned()),
instance: Some(self.config.instance.clone()),
full_text: text,
align: Some(s::Align::Left),

Loading…
Cancel
Save