parent
7450393e97
commit
60799fb544
3 changed files with 41 additions and 15 deletions
7
Cargo.lock
generated
7
Cargo.lock
generated
|
|
@ -1269,6 +1269,7 @@ dependencies = [
|
||||||
"tracing",
|
"tracing",
|
||||||
"tracing-subscriber",
|
"tracing-subscriber",
|
||||||
"urlencoding",
|
"urlencoding",
|
||||||
|
"ward",
|
||||||
"zbus",
|
"zbus",
|
||||||
"zvariant",
|
"zvariant",
|
||||||
]
|
]
|
||||||
|
|
@ -1860,6 +1861,12 @@ version = "1.1.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "9d5b2c62b4012a3e1eca5a7e077d13b3bf498c4073e33ccd58626607748ceeca"
|
checksum = "9d5b2c62b4012a3e1eca5a7e077d13b3bf498c4073e33ccd58626607748ceeca"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "ward"
|
||||||
|
version = "2.1.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "1cbcd609d606e1307a1530061482ed2ee3fc9963128990238cefb2013127b61e"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wasi"
|
name = "wasi"
|
||||||
version = "0.10.2+wasi-snapshot-preview1"
|
version = "0.10.2+wasi-snapshot-preview1"
|
||||||
|
|
|
||||||
|
|
@ -29,3 +29,4 @@ tracing-subscriber = "0.2"
|
||||||
urlencoding = "2"
|
urlencoding = "2"
|
||||||
zbus = "1"
|
zbus = "1"
|
||||||
zvariant = "=2.6" # Restrict for 1.47
|
zvariant = "=2.6" # Restrict for 1.47
|
||||||
|
ward = "2.1.0"
|
||||||
|
|
|
||||||
|
|
@ -94,26 +94,44 @@ impl<W: AsyncWrite + Unpin> App<W> {
|
||||||
for (src, path) in DesktopIter::new(default_paths()) {
|
for (src, path) in DesktopIter::new(default_paths()) {
|
||||||
if let Ok(bytes) = std::fs::read_to_string(&path) {
|
if let Ok(bytes) = std::fs::read_to_string(&path) {
|
||||||
if let Ok(entry) = DesktopEntry::decode(&path, &bytes) {
|
if let Ok(entry) = DesktopEntry::decode(&path, &bytes) {
|
||||||
// If defined to only show in a specific DE, avoid showing it if invalid.
|
// Do not show if our desktop is defined in `NotShowIn`.
|
||||||
let mut desktop_matched = false;
|
if let Some(not_show_in) = entry.desktop_entry("NotShowIn") {
|
||||||
if let Some(desktops) = entry.only_show_in() {
|
let current = ward::ward!(current.as_ref(), else { continue });
|
||||||
desktop_matched = match current.as_ref() {
|
|
||||||
Some(current) => desktops
|
|
||||||
.to_ascii_lowercase()
|
|
||||||
.split(';')
|
|
||||||
.any(|desktop| current.iter().any(|c| *c == desktop)),
|
|
||||||
None => false,
|
|
||||||
};
|
|
||||||
|
|
||||||
if !desktop_matched {
|
let matched = not_show_in
|
||||||
|
.to_ascii_lowercase()
|
||||||
|
.split(';')
|
||||||
|
.any(|desktop| current.iter().any(|c| *c == desktop));
|
||||||
|
|
||||||
|
if matched {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if entry.no_display()
|
// Track this condition so that we can override `NoDisplay` if this is true.
|
||||||
&& (!desktop_matched
|
let mut only_show_in = false;
|
||||||
|| entry.name(None).map_or(false, |v| v == "GNOME Shell"))
|
|
||||||
{
|
// Do not show if our desktop is not defined in `OnlyShowIn`.
|
||||||
|
if let Some(desktops) = entry.only_show_in() {
|
||||||
|
let current = ward::ward!(current.as_ref(), else { continue });
|
||||||
|
|
||||||
|
only_show_in = desktops
|
||||||
|
.to_ascii_lowercase()
|
||||||
|
.split(';')
|
||||||
|
.any(|desktop| current.iter().any(|c| *c == desktop));
|
||||||
|
|
||||||
|
if !only_show_in {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Avoid showing the GNOME Shell entry entirely
|
||||||
|
if entry.name(None).map_or(false, |v| v == "GNOME Shell") {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// And also avoid showing anything that's set as `NoDisplay`
|
||||||
|
if !only_show_in && entry.no_display() {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue