mirror of
https://github.com/chmln/handlr.git
synced 2024-11-14 21:49:27 +01:00
parent
513d68d1bd
commit
e86d7dd316
1 changed files with 19 additions and 12 deletions
|
@ -165,6 +165,9 @@ impl MimeApps {
|
||||||
xdg::BaseDirectories::new()?
|
xdg::BaseDirectories::new()?
|
||||||
.list_data_files_once("applications")
|
.list_data_files_once("applications")
|
||||||
.into_iter()
|
.into_iter()
|
||||||
|
.filter(|p| {
|
||||||
|
p.extension().map(|x| x.to_str()).flatten() == Some("desktop")
|
||||||
|
})
|
||||||
.filter_map(|p| DesktopEntry::try_from(p).ok())
|
.filter_map(|p| DesktopEntry::try_from(p).ok())
|
||||||
.for_each(|e| {
|
.for_each(|e| {
|
||||||
stdout.write_all(e.file_name.as_bytes()).unwrap();
|
stdout.write_all(e.file_name.as_bytes()).unwrap();
|
||||||
|
@ -201,19 +204,23 @@ impl SystemApps {
|
||||||
})
|
})
|
||||||
.filter_map(|data_dir| std::fs::read_dir(data_dir).ok())
|
.filter_map(|data_dir| std::fs::read_dir(data_dir).ok())
|
||||||
.for_each(|dir| {
|
.for_each(|dir| {
|
||||||
dir.filter_map(|path| {
|
dir.filter_map(Result::ok)
|
||||||
path.ok()
|
.filter(|p| {
|
||||||
.map(|p| DesktopEntry::try_from(p.path()).ok())
|
p.path()
|
||||||
.flatten()
|
.extension()
|
||||||
})
|
.map(std::ffi::OsStr::to_str)
|
||||||
.for_each(|entry| {
|
.flatten()
|
||||||
let (file_name, mimes) = (entry.file_name, entry.mimes);
|
== Some("desktop")
|
||||||
mimes.into_iter().for_each(|mime| {
|
})
|
||||||
map.entry(mime)
|
.filter_map(|p| DesktopEntry::try_from(p.path()).ok())
|
||||||
.or_default()
|
.for_each(|entry| {
|
||||||
.push(Handler::assume_valid(file_name.clone()));
|
let (file_name, mimes) = (entry.file_name, entry.mimes);
|
||||||
|
mimes.into_iter().for_each(|mime| {
|
||||||
|
map.entry(mime)
|
||||||
|
.or_default()
|
||||||
|
.push(Handler::assume_valid(file_name.clone()));
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
Ok(Self(map))
|
Ok(Self(map))
|
||||||
|
|
Loading…
Reference in a new issue