run AppImage files from cosmic-files
This commit is contained in:
parent
5e0ef57ef8
commit
72101ca296
2 changed files with 46 additions and 20 deletions
65
src/app.rs
65
src/app.rs
|
|
@ -41,15 +41,7 @@ use notify_debouncer_full::{
|
||||||
};
|
};
|
||||||
use slotmap::Key as SlotMapKey;
|
use slotmap::Key as SlotMapKey;
|
||||||
use std::{
|
use std::{
|
||||||
any::TypeId,
|
any::TypeId, collections::{BTreeMap, HashMap, HashSet, VecDeque}, env, ffi::OsStr, fmt, fs, future::pending, io::{BufRead, BufReader}, num::NonZeroU16, os::unix::fs::PermissionsExt, path::PathBuf, process, sync::{Arc, Mutex}, time::{self, Instant}
|
||||||
collections::{BTreeMap, HashMap, HashSet, VecDeque},
|
|
||||||
env, fmt, fs,
|
|
||||||
future::pending,
|
|
||||||
num::NonZeroU16,
|
|
||||||
path::PathBuf,
|
|
||||||
process,
|
|
||||||
sync::{Arc, Mutex},
|
|
||||||
time::{self, Instant},
|
|
||||||
};
|
};
|
||||||
use tokio::sync::mpsc;
|
use tokio::sync::mpsc;
|
||||||
use trash::TrashItem;
|
use trash::TrashItem;
|
||||||
|
|
@ -2350,18 +2342,51 @@ impl Application for App {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
if !found_desktop_exec {
|
if !found_desktop_exec {
|
||||||
match open::that_detached(&path) {
|
let file_extension = path.extension();
|
||||||
Ok(()) => {
|
match file_extension {
|
||||||
let _ = recently_used_xbel::update_recently_used(
|
Some(ext) if ext == OsStr::new("AppImage") => {
|
||||||
&path,
|
// Set the executable permission to the file
|
||||||
App::APP_ID.to_string(),
|
let mut perms = fs::metadata(&path)
|
||||||
"cosmic-files".to_string(),
|
.expect("Failed to get metadata")
|
||||||
None,
|
.permissions();
|
||||||
);
|
// Set the executable permission to the file
|
||||||
}
|
perms.set_mode(0o755);
|
||||||
Err(err) => {
|
fs::set_permissions(&path, perms).expect("Failed to set permissions");
|
||||||
log::warn!("failed to open {:?}: {}", path, err);
|
|
||||||
|
log::info!("running app: {:?}", ext);
|
||||||
|
let cmd = std::process::Command::new(path).spawn();
|
||||||
|
match cmd {
|
||||||
|
Ok(mut res) => {
|
||||||
|
if let Some(stderr) = res.stderr.take() {
|
||||||
|
let reader = BufReader::new(stderr);
|
||||||
|
for line in reader.lines() {
|
||||||
|
if let Ok(line) = line {
|
||||||
|
log::error!(
|
||||||
|
"running app error: {}",
|
||||||
|
line
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Err(error) => {
|
||||||
|
log::error!("error: {:?}", error);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
_ => match open::that_detached(&path) {
|
||||||
|
Ok(()) => {
|
||||||
|
let _ = recently_used_xbel::update_recently_used(
|
||||||
|
&path,
|
||||||
|
App::APP_ID.to_string(),
|
||||||
|
"cosmic-files".to_string(),
|
||||||
|
None,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
Err(err) => {
|
||||||
|
log::warn!("failed to open {:?}: {}", path, err);
|
||||||
|
}
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,7 @@ pub fn exec_to_command(exec: &str, path_opt: Option<PathBuf>) -> Option<process:
|
||||||
command.arg(arg);
|
command.arg(arg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
log::info!("command: {:?}", command);
|
||||||
Some(command)
|
Some(command)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue