update deps

This commit is contained in:
Ashley Wulber 2024-07-16 18:22:01 -04:00 committed by Ashley Wulber
parent 68af00a29e
commit eaeee04f1e
5 changed files with 132 additions and 142 deletions

View file

@ -5,10 +5,10 @@ edition = "2021"
license = "GPL-3.0"
[dependencies]
freedesktop-desktop-entry = "0.5.1"
freedesktop-desktop-entry = "0.6.2"
libcosmic.workspace = true
tracing-log.workspace = true
tracing-subscriber.workspace = true
tracing.workspace = true
cosmic-config.workspace = true
serde.workspace = true
serde.workspace = true

View file

@ -16,7 +16,7 @@ use cosmic::{
widget::vertical_space,
};
use cosmic_config::{Config, CosmicConfigEntry};
use freedesktop_desktop_entry::DesktopEntry;
use freedesktop_desktop_entry::{get_languages_from_env, DesktopEntry};
use std::{env, fs, process::Command};
mod config;
@ -153,20 +153,22 @@ pub fn main() -> iced::Result {
.expect("Requires desktop file id as argument.");
let filename = format!("{id}.desktop");
let mut desktop = None;
let locales = get_languages_from_env();
for mut path in freedesktop_desktop_entry::default_paths() {
path.push(&filename);
if let Ok(bytes) = fs::read_to_string(&path) {
if let Ok(entry) = DesktopEntry::decode(&path, &bytes) {
desktop =
Some(Desktop {
name: entry.name(None).map(|x| x.to_string()).unwrap_or_else(|| {
panic!("Desktop file '{filename}' doesn't have `Name`")
}),
icon: entry.icon().map(|x| x.to_string()),
exec: entry.exec().map(|x| x.to_string()).unwrap_or_else(|| {
panic!("Desktop file '{filename}' doesn't have `Exec`")
}),
});
if let Ok(entry) = DesktopEntry::from_str(&path, &bytes, &locales) {
desktop = Some(Desktop {
name: entry
.name(&locales)
.map(|x| x.to_string())
.unwrap_or_else(|| panic!("Desktop file '{filename}' doesn't have `Name`")),
icon: entry.icon().map(|x| x.to_string()),
exec: entry
.exec()
.map(|x| x.to_string())
.unwrap_or_else(|| panic!("Desktop file '{filename}' doesn't have `Exec`")),
});
break;
}
}