[PATCH wldash 1/1] feat: deduplicate desktop entries
Export this patch
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.
---
Cargo.lock | 16 ++++++++++++++++
Cargo.toml | 1 +
src/desktop.rs | 2 ++
3 files changed, 19 insertions(+)
diff --git a/Cargo.lock b/Cargo.lock
index 96bd23d..d9f9feb 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -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"
@@ -762,6 +777,7 @@ dependencies = [
"dlib",
"fontconfig",
"fuzzy-matcher",
+ "itertools",
"lazy_static",
"libpulse-binding",
"memmap",
diff --git a/Cargo.toml b/Cargo.toml
index c3fc985..eb31c01 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -37,6 +37,7 @@ rcalc_lib = "0.9"
rust-ini = "0.14"
shlex = "0.1"
timerfd = "1.0.0"
+ itertools = "0.10.3"
serde = { version = "1.0", features = ["derive"] }
serde_json = { version = "1.0", optional = true }
diff --git a/src/desktop.rs b/src/desktop.rs
index 2f8e822..27a7d0b 100644
--- a/src/desktop.rs
+++ b/src/desktop.rs
@@ -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()
}
--
2.34.1
wldash/patches/.build.yml: SUCCESS in 2m28s
[Remove duplicate desktop entries][0] from [Cyril Levis][1]
[0]: https://lists.sr.ht/~kennylevinsen/public-inbox/patches/27663
[1]: mailto:git@levis.name
✓ #656694 SUCCESS wldash/patches/.build.yml https://builds.sr.ht/~kennylevinsen/job/656694
Applied, thanks!