diff --git a/plugins/applications/src/lib.rs b/plugins/applications/src/lib.rs index d111170..7b3a74a 100644 --- a/plugins/applications/src/lib.rs +++ b/plugins/applications/src/lib.rs @@ -105,8 +105,13 @@ pub fn get_matches(input: RString, state: &State) -> RVec { .entries .iter() .filter_map(|(entry, id)| { - let score = matcher.fuzzy_match(&entry.name, &input).unwrap_or(0) - + matcher.fuzzy_match(&entry.exec, &input).unwrap_or(0); + let score: i64 = matcher.fuzzy_match(&entry.name, &input).unwrap_or(0) + + matcher.fuzzy_match(&entry.exec, &input).unwrap_or(0) + + entry + .keywords + .iter() + .map(|keyword| matcher.fuzzy_match(keyword, &input).unwrap_or(0)) + .sum::(); if score > 0 { Some((entry, *id, score)) diff --git a/plugins/applications/src/scrubber.rs b/plugins/applications/src/scrubber.rs index 87d58c0..1423c63 100644 --- a/plugins/applications/src/scrubber.rs +++ b/plugins/applications/src/scrubber.rs @@ -7,6 +7,7 @@ pub struct DesktopEntry { pub exec: String, pub path: Option, pub name: String, + pub keywords: Vec, pub desc: Option, pub icon: String, pub term: bool, @@ -76,6 +77,15 @@ impl DesktopEntry { }, path: map.get("Path").map(PathBuf::from), name: map.get("Name")?.to_string(), + keywords: map + .get("Keywords") + .map(|keywords| { + keywords + .split(';') + .map(|s| s.to_owned()) + .collect::>() + }) + .unwrap_or_default(), desc: None, icon: map .get("Icon") @@ -125,6 +135,15 @@ impl DesktopEntry { Some(name) => name.to_string(), None => continue, }, + keywords: map + .get("Keywords") + .map(|keywords| { + keywords + .split(';') + .map(|s| s.to_owned()) + .collect::>() + }) + .unwrap_or_default(), desc: Some(entry.name.clone()), icon: entry.icon.clone(), term: map