Skip to content

Commit 2b415c9

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 f85ba0d commit 2b415c9

File tree

4 files changed

+363
-12
lines changed

4 files changed

+363
-12
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
]
@@ -96,11 +97,14 @@ cosmic-settings-daemon = { git = "https://github.com/pop-os/dbus-settings-bindin
9697
css-color = "0.2.5"
9798
derive_setters = "0.1.5"
9899
fraction = "0.15.3"
100+
icu_collator = "1.5"
99101
image = { version = "0.25.1", optional = true }
100102
lazy_static = "1.4.0"
101103
libc = { version = "0.2.155", optional = true }
102104
license = { version = "3.5.1", optional = true }
103105
mime = { version = "0.3.17", optional = true }
106+
mime_guess = "2"
107+
once_cell = "1.19"
104108
palette = "0.7.3"
105109
rfd = { version = "0.14.0", optional = true }
106110
rustix = { version = "0.38.34", features = [
@@ -116,11 +120,13 @@ tracing = "0.1"
116120
unicode-segmentation = "1.6"
117121
url = "2.4.0"
118122
ustr = { version = "1.0.0", features = ["serde"] }
123+
xdg = { version = "2.5.2", optional = true }
119124
zbus = { version = "4.2.1", default-features = false, optional = true }
120125

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

126132
[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)