Skip to content

Commit 8128184

Browse files
committed
refactor: remove prefer_non_default arg gpu and use desktop entry attribute instead
1 parent 8d06564 commit 8128184

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

src/exec/dbus.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ impl DesktopEntry<'_> {
2727
&self,
2828
conn: &Connection,
2929
uris: &[&str],
30-
prefer_non_default_gpu: bool,
3130
) -> Result<(), ExecError> {
3231
let dbus_path = self.appid.replace('.', "/");
3332
let dbus_path = format!("/{dbus_path}");
@@ -37,7 +36,7 @@ impl DesktopEntry<'_> {
3736
.build()?;
3837

3938
let mut platform_data = HashMap::new();
40-
if prefer_non_default_gpu {
39+
if self.prefers_non_default_gpu() {
4140
let gpus = Gpus::load();
4241
if let Some(gpu) = gpus.non_default() {
4342
for (opt, value) in gpu.launch_options() {

src/exec/mod.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,21 @@ mod graphics;
1616
impl DesktopEntry<'_> {
1717
/// Launch the given desktop entry either via dbus or via its `Exec` key with the default gpu or
1818
/// the alternative one if available.
19-
pub fn launch(&self, uris: &[&str], prefer_non_default_gpu: bool) -> Result<(), ExecError> {
19+
pub fn launch(&self, uris: &[&str]) -> Result<(), ExecError> {
20+
2021
match Connection::session() {
2122
Ok(conn) => {
2223
if self.is_bus_actionable(&conn) {
23-
self.dbus_launch(&conn, uris, prefer_non_default_gpu)
24+
self.dbus_launch(&conn, uris)
2425
} else {
25-
self.shell_launch(uris, prefer_non_default_gpu)
26+
self.shell_launch(uris)
2627
}
2728
}
28-
Err(_) => self.shell_launch(uris, prefer_non_default_gpu),
29+
Err(_) => self.shell_launch(uris),
2930
}
3031
}
3132

32-
fn shell_launch(&self, uris: &[&str], prefer_non_default_gpu: bool) -> Result<(), ExecError> {
33+
fn shell_launch(&self, uris: &[&str]) -> Result<(), ExecError> {
3334
let exec = self.exec();
3435
if exec.is_none() {
3536
return Err(ExecError::MissingExecKey(self.path));
@@ -68,7 +69,7 @@ impl DesktopEntry<'_> {
6869
let args = format!("{terminal} {separator} {exec_args}");
6970
let args = ["-c", &args];
7071
let mut cmd = Command::new(shell);
71-
if prefer_non_default_gpu {
72+
if self.prefers_non_default_gpu() {
7273
with_non_default_gpu(cmd)
7374
} else {
7475
cmd
@@ -79,7 +80,7 @@ impl DesktopEntry<'_> {
7980
} else {
8081
let mut cmd = Command::new(shell);
8182

82-
if prefer_non_default_gpu {
83+
if self.prefers_non_default_gpu() {
8384
with_non_default_gpu(cmd)
8485
} else {
8586
cmd

0 commit comments

Comments
 (0)