mirror of
https://github.com/Zedfrigg/ironbar.git
synced 2025-04-19 19:34:24 +02:00
refactor: fix a couple of clippy warnings
This commit is contained in:
parent
8576ac5c44
commit
7625635050
4 changed files with 29 additions and 23 deletions
|
@ -41,7 +41,7 @@ pub enum BarPosition {
|
||||||
|
|
||||||
impl Default for BarPosition {
|
impl Default for BarPosition {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
BarPosition::Bottom
|
Self::Bottom
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,7 +71,13 @@ impl Config {
|
||||||
pub fn load() -> Option<Self> {
|
pub fn load() -> Option<Self> {
|
||||||
if let Ok(config_path) = env::var("IRONBAR_CONFIG") {
|
if let Ok(config_path) = env::var("IRONBAR_CONFIG") {
|
||||||
let path = PathBuf::from(config_path);
|
let path = PathBuf::from(config_path);
|
||||||
Config::load_file(&path, path.extension().unwrap_or_default().to_str().unwrap_or_default())
|
Self::load_file(
|
||||||
|
&path,
|
||||||
|
path.extension()
|
||||||
|
.unwrap_or_default()
|
||||||
|
.to_str()
|
||||||
|
.unwrap_or_default(),
|
||||||
|
)
|
||||||
} else {
|
} else {
|
||||||
let config_dir = config_dir().expect("Failed to locate user config dir");
|
let config_dir = config_dir().expect("Failed to locate user config dir");
|
||||||
|
|
||||||
|
@ -82,7 +88,7 @@ impl Config {
|
||||||
.join("ironbar")
|
.join("ironbar")
|
||||||
.join(format!("config.{extension}"));
|
.join(format!("config.{extension}"));
|
||||||
|
|
||||||
Config::load_file(&full_path, extension)
|
Self::load_file(&full_path, extension)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
29
src/main.rs
29
src/main.rs
|
@ -48,22 +48,25 @@ async fn main() {
|
||||||
.expect("GTK monitor output differs from Sway's")
|
.expect("GTK monitor output differs from Sway's")
|
||||||
.name;
|
.name;
|
||||||
|
|
||||||
if let Some(ref config) = config.monitors {
|
config.monitors.as_ref().map_or_else(
|
||||||
let config = config.get(monitor_name);
|
|| {
|
||||||
match &config {
|
create_bar(app, &monitor, monitor_name, config.clone());
|
||||||
Some(MonitorConfig::Single(config)) => {
|
},
|
||||||
create_bar(app, &monitor, monitor_name, config.clone());
|
|config| {
|
||||||
}
|
let config = config.get(monitor_name);
|
||||||
Some(MonitorConfig::Multiple(configs)) => {
|
match &config {
|
||||||
for config in configs {
|
Some(MonitorConfig::Single(config)) => {
|
||||||
create_bar(app, &monitor, monitor_name, config.clone());
|
create_bar(app, &monitor, monitor_name, config.clone());
|
||||||
}
|
}
|
||||||
|
Some(MonitorConfig::Multiple(configs)) => {
|
||||||
|
for config in configs {
|
||||||
|
create_bar(app, &monitor, monitor_name, config.clone());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_ => {}
|
||||||
}
|
}
|
||||||
_ => {}
|
},
|
||||||
}
|
)
|
||||||
} else {
|
|
||||||
create_bar(app, &monitor, monitor_name, config.clone());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let style_path = config_dir()
|
let style_path = config_dir()
|
||||||
|
|
|
@ -73,10 +73,7 @@ impl Module<gtk::Box> for FocusedModule {
|
||||||
|
|
||||||
{
|
{
|
||||||
rx.attach(None, move |node| {
|
rx.attach(None, move |node| {
|
||||||
let value = node
|
let value = node.name.as_deref().unwrap_or_else(|| node.get_id());
|
||||||
.name
|
|
||||||
.as_deref()
|
|
||||||
.unwrap_or_else(|| node.get_id());
|
|
||||||
|
|
||||||
let pixbuf = icon::get_icon(&icon_theme, node.get_id(), self.icon_size);
|
let pixbuf = icon::get_icon(&icon_theme, node.get_id(), self.icon_size);
|
||||||
|
|
||||||
|
|
|
@ -51,13 +51,13 @@ impl Module<gtk::Box> for WorkspacesModule {
|
||||||
let raw = sway.ipc(IpcCommand::GetWorkspaces).unwrap();
|
let raw = sway.ipc(IpcCommand::GetWorkspaces).unwrap();
|
||||||
let workspaces = serde_json::from_slice::<Vec<Workspace>>(&raw).unwrap();
|
let workspaces = serde_json::from_slice::<Vec<Workspace>>(&raw).unwrap();
|
||||||
|
|
||||||
if !self.all_monitors {
|
if self.all_monitors {
|
||||||
|
workspaces
|
||||||
|
} else {
|
||||||
workspaces
|
workspaces
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.filter(|workspace| workspace.output == info.output_name)
|
.filter(|workspace| workspace.output == info.output_name)
|
||||||
.collect()
|
.collect()
|
||||||
} else {
|
|
||||||
workspaces
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue