Skip to content

Commit b450653

Browse files
committed
Copy mime_app from cosmic-files
- Add optional language sorter parameter to MimeAppCache::reload() - Use mime_app::exec_term_command in desktop::spawn_desktop_exec() - Add function mime_app::exec_term_to_command() to get exec command using terminal with fallback - Use this in MimeApp::command() - Use this in desktop::spawn_desktop_exec()
1 parent 1e58854 commit b450653

File tree

5 files changed

+364
-13
lines changed

5 files changed

+364
-13
lines changed

Cargo.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ desktop = [
4343
"dep:freedesktop-desktop-entry",
4444
"dep:mime",
4545
"dep:shlex",
46+
"dep:xdg",
4647
"tokio?/io-util",
4748
"tokio?/net",
4849
]
@@ -95,11 +96,14 @@ cosmic-config = { path = "cosmic-config" }
9596
cosmic-settings-daemon = { git = "https://github.com/pop-os/dbus-settings-bindings", optional = true }
9697
css-color = "0.2.5"
9798
derive_setters = "0.1.5"
99+
icu_collator = "1.5"
98100
image = { version = "0.25.1", optional = true }
99101
lazy_static = "1.4.0"
100102
libc = { version = "0.2.155", optional = true }
101103
license = { version = "3.5.1", optional = true }
102104
mime = { version = "0.3.17", optional = true }
105+
mime_guess = "2"
106+
once_cell = "1.19"
103107
palette = "0.7.3"
104108
rfd = { version = "0.14.0", optional = true }
105109
rustix = { version = "0.38.34", features = [
@@ -115,11 +119,13 @@ tracing = "0.1"
115119
unicode-segmentation = "1.6"
116120
url = "2.4.0"
117121
ustr = { version = "1.0.0", features = ["serde"] }
122+
xdg = { version = "2.5.2", optional = true }
118123
zbus = { version = "4.2.1", default-features = false, optional = true }
119124

120125
[target.'cfg(unix)'.dependencies]
121126
freedesktop-icons = "0.2.5"
122127
freedesktop-desktop-entry = { version = "0.5.1", optional = true }
128+
freedesktop_entry_parser = "1.3"
123129
shlex = { version = "1.3.0", optional = true }
124130

125131
[dependencies.cosmic-theme]

src/desktop.rs

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ use std::{
66
path::{Path, PathBuf},
77
};
88

9+
use crate::mime_app::{exec_term_to_command, exec_to_command};
10+
911
#[derive(Debug, Clone, PartialEq, Eq)]
1012
pub enum IconSource {
1113
Name(String),
@@ -249,21 +251,14 @@ pub async fn spawn_desktop_exec<S, I, K, V>(
249251
_ => return,
250252
};
251253

252-
let mut cmd = if terminal {
253-
let mut cmd = std::process::Command::new("cosmic-term");
254-
cmd.args(vec!["--", format!("{}", &executable).as_str()]);
255-
cmd
254+
let cmd = if terminal {
255+
exec_term_to_command(&executable, None)
256256
} else {
257-
let mut cmd = std::process::Command::new(&executable);
258-
for arg in exec {
259-
// TODO handle "%" args here if necessary?
260-
if !arg.starts_with('%') {
261-
cmd.arg(arg);
262-
}
263-
}
264-
cmd
257+
exec_to_command(&executable, None)
265258
};
266259

260+
let Some(mut cmd) = cmd else { return };
261+
267262
cmd.envs(env_vars);
268263

269264
// https://systemd.io/DESKTOP_ENVIRONMENTS

src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ pub mod keyboard_nav;
7575

7676
#[cfg(feature = "desktop")]
7777
pub mod desktop;
78+
79+
pub mod mime_app;
80+
7881
#[cfg(feature = "process")]
7982
pub mod process;
8083

0 commit comments

Comments
 (0)