Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 16 additions & 6 deletions plugins/applications/src/scrubber.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ pub struct DesktopEntry {
pub icon: String,
pub term: bool,
pub offset: i64,
pub ignored: bool,
}

const FIELD_CODE_LIST: &[&str] = &[
Expand Down Expand Up @@ -50,6 +51,7 @@ impl DesktopEntry {
}

let mut ret = Vec::new();
let mut ignored = false;

let entry = match new_sections.iter().find_map(|section| {
if section[0].starts_with("[Desktop Entry]") {
Expand All @@ -61,12 +63,17 @@ impl DesktopEntry {
}
}

if map.get("Type")? == &"Application"
&& match map.get("NoDisplay") {
Some(no_display) => !no_display.parse::<bool>().unwrap_or(true),
None => true,
}
{
let no_display = map
.get("NoDisplay")
.and_then(|no_display| no_display.parse::<bool>().ok())
.unwrap_or(false);
let hidden = map
.get("Hidden")
.and_then(|hidden| hidden.parse::<bool>().ok())
.unwrap_or(false);
ignored = hidden || no_display;

if map.get("Type")? == &"Application" {
Some(DesktopEntry {
exec: {
let mut exec = map.get("Exec")?.to_string();
Expand Down Expand Up @@ -97,6 +104,7 @@ impl DesktopEntry {
.map(|val| val.to_lowercase() == "true")
.unwrap_or(false),
offset: 0,
ignored,
})
} else {
None
Expand Down Expand Up @@ -153,6 +161,7 @@ impl DesktopEntry {
.map(|val| val.to_lowercase() == "true")
.unwrap_or(false),
offset: i as i64,
ignored,
})
}
}
Expand Down Expand Up @@ -246,6 +255,7 @@ pub fn scrubber(config: &Config) -> Result<Vec<(DesktopEntry, u64)>, Box<dyn std

Ok(entries
.into_iter()
.filter(|(_, entry)| !entry.ignored)
.enumerate()
.map(|(i, (_, entry))| (entry, i as u64))
.collect())
Expand Down