feat: deduplicate desktop entries

We don't want duplicate entries because there are not distinguishable by Name.

People will sometimes override in there HOME dir some desktop files entries
in order to do some modifications.

The actual reading order is good and so `unique_by` name do the job.
This commit is contained in:
Cyril Levis
2021-12-30 22:10:51 +01:00
committed by Kenny Levinsen
parent d4f62da6f5
commit fe37c15f95
3 changed files with 19 additions and 0 deletions
Generated
+16
View File
@@ -152,6 +152,12 @@ version = "0.4.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "88d7ed2934d741c6b37e33e3832298e8850b53fd2d2bea03873375596c7cea4e"
[[package]]
name = "either"
version = "1.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457"
[[package]]
name = "fake-simd"
version = "0.1.2"
@@ -185,6 +191,15 @@ dependencies = [
"typenum",
]
[[package]]
name = "itertools"
version = "0.10.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a9a9d19fa1e79b6215ff29b9d6880b706147f16e9b1dbb1e4e5947b5b02bc5e3"
dependencies = [
"either",
]
[[package]]
name = "itoa"
version = "0.4.7"
@@ -791,6 +806,7 @@ dependencies = [
"dlib",
"fontconfig",
"fuzzy-matcher",
"itertools",
"lazy_static",
"libpulse-binding",
"memmap",
+1
View File
@@ -38,6 +38,7 @@ rust-ini = "0.14"
shlex = "0.1"
timerfd = "1.0.0"
walkdir = "2.3.2"
itertools = "0.10.3"
serde = { version = "1.0", features = ["derive"] }
serde_json = { version = "1.0", optional = true }
+2
View File
@@ -1,5 +1,6 @@
extern crate ini;
use ini::{Ini, ParseOption};
use itertools::Itertools;
use std::cmp::Ordering;
use std::env;
use std::error::Error;
@@ -107,5 +108,6 @@ pub fn load_desktop_files() -> Vec<Desktop> {
.filter(|d| {
!d.hidden && !d.no_display && (d.entry_type == "Application" || d.entry_type == "Link")
})
.unique_by(|x| x.name.clone())
.collect()
}