Skip to content

Commit

Permalink
chore: cargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
oknozor committed May 29, 2022
1 parent ad7205c commit b33c9b3
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 39 deletions.
72 changes: 36 additions & 36 deletions plugins/src/desktop_entries/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

mod graphics;

use crate::desktop_entries::graphics::is_switchable;
use crate::*;
use freedesktop_desktop_entry::{default_paths, DesktopEntry, Iter as DesktopIter, PathSource};
use futures::StreamExt;
Expand All @@ -12,7 +13,6 @@ use std::hash::{Hash, Hasher};
use std::process::Command;
use tokio::io::AsyncWrite;
use tracing::error;
use crate::desktop_entries::graphics::is_switchable;

#[derive(Debug, Eq)]
struct Item {
Expand All @@ -30,7 +30,7 @@ struct Item {
#[derive(Debug, PartialEq, Eq)]
pub enum ContextAction {
Action(Action),
GpuPreference(GpuPreference)
GpuPreference(GpuPreference),
}

impl Item {
Expand All @@ -39,18 +39,18 @@ impl Item {
// No action provided just run the desktop entry with the default gpu
None => run_exec_command(&self.exec, self.prefer_non_default_gpu),
// Run the provided action
Some(idx) => {
match self.context.get(idx as usize) {
None => error!("Could not find context action at index {idx}"),
Some(action) => match action {
ContextAction::Action(action) => run_exec_command(&action.exec, self.prefer_non_default_gpu),
ContextAction::GpuPreference(pref) => match pref {
GpuPreference::Default => run_exec_command(&self.exec, false),
GpuPreference::NonDefault => run_exec_command(&self.exec, true),
},
Some(idx) => match self.context.get(idx as usize) {
None => error!("Could not find context action at index {idx}"),
Some(action) => match action {
ContextAction::Action(action) => {
run_exec_command(&action.exec, self.prefer_non_default_gpu)
}
ContextAction::GpuPreference(pref) => match pref {
GpuPreference::Default => run_exec_command(&self.exec, false),
GpuPreference::NonDefault => run_exec_command(&self.exec, true),
},
}
}
},
},
}
}
}
Expand Down Expand Up @@ -238,19 +238,21 @@ impl<W: AsyncWrite + Unpin> App<W> {
.map(|action| ContextAction::Action(action));

let entry_prefers_non_default_gpu = entry.prefers_non_default_gpu();
let prefer_non_default_gpu = entry_prefers_non_default_gpu && is_switchable();
let prefer_default_gpu = !entry_prefers_non_default_gpu && is_switchable();
let prefer_non_default_gpu =
entry_prefers_non_default_gpu && is_switchable();
let prefer_default_gpu =
!entry_prefers_non_default_gpu && is_switchable();

let context: Vec<ContextAction> = if prefer_non_default_gpu {
let context: Vec<ContextAction> = if prefer_non_default_gpu {
vec![ContextAction::GpuPreference(GpuPreference::Default)]
} else if prefer_default_gpu {
vec![ContextAction::GpuPreference(GpuPreference::NonDefault)]
} else {
vec![]
}
.into_iter()
.chain(actions)
.collect();
.into_iter()
.chain(actions)
.collect();

let item = Item {
appid: entry.appid.to_owned(),
Expand All @@ -267,7 +269,7 @@ impl<W: AsyncWrite + Unpin> App<W> {
exec: exec.to_owned(),
src,
context,
prefer_non_default_gpu: entry_prefers_non_default_gpu
prefer_non_default_gpu: entry_prefers_non_default_gpu,
};

deduplicator.insert(item);
Expand Down Expand Up @@ -312,22 +314,20 @@ impl<W: AsyncWrite + Unpin> App<W> {
description: action.description.to_owned(),
exec: Some(action.exec.to_string()),
}),
ContextAction::GpuPreference(pref) => {
match pref {
GpuPreference::Default => options.push(ContextOption {
id: 0,
name: "Integrated Graphics".to_owned(),
description: "Launch Using Integrated Graphics Card".to_owned(),
exec: None,
}),
GpuPreference::NonDefault => options.push(ContextOption {
id: 0,
name: "Discrete Graphics".to_owned(),
description: "Launch Using Discrete Graphics Card".to_owned(),
exec: None,
}),
}
}
ContextAction::GpuPreference(pref) => match pref {
GpuPreference::Default => options.push(ContextOption {
id: 0,
name: "Integrated Graphics".to_owned(),
description: "Launch Using Integrated Graphics Card".to_owned(),
exec: None,
}),
GpuPreference::NonDefault => options.push(ContextOption {
id: 0,
name: "Discrete Graphics".to_owned(),
description: "Launch Using Discrete Graphics Card".to_owned(),
exec: None,
}),
},
}
}

Expand Down
2 changes: 1 addition & 1 deletion plugins/src/web/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use url::Url;

use pop_launcher::*;

pub use config::{Config, Definition, load};
pub use config::{load, Config, Definition};
use regex::Regex;

mod config;
Expand Down
2 changes: 1 addition & 1 deletion service/src/plugins/help.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pub const CONFIG: PluginConfig = PluginConfig {
regex: None,
},
icon: Some(IconSource::Name(Cow::Borrowed("system-help-symbolic"))),
history: false
history: false,
};
pub struct HelpPlugin {
pub id: usize,
Expand Down
2 changes: 1 addition & 1 deletion service/src/plugins/mod.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// Copyright 2021 System76 <[email protected]>
// SPDX-License-Identifier: MPL-2.0

pub(crate) mod external;
pub mod config;
pub(crate) mod external;
pub mod help;

pub use external::load;
Expand Down

0 comments on commit b33c9b3

Please sign in to comment.