chore: use libcosmic's freedesktop-desktop-entry
This commit is contained in:
parent
f13961274a
commit
4acdc099f4
3 changed files with 10 additions and 16 deletions
11
Cargo.lock
generated
11
Cargo.lock
generated
|
|
@ -1308,7 +1308,6 @@ dependencies = [
|
||||||
"cosmic-settings-daemon-config",
|
"cosmic-settings-daemon-config",
|
||||||
"cosmic-settings-subscriptions",
|
"cosmic-settings-subscriptions",
|
||||||
"dirs 6.0.0",
|
"dirs 6.0.0",
|
||||||
"freedesktop_entry_parser",
|
|
||||||
"futures-util",
|
"futures-util",
|
||||||
"greetd_ipc",
|
"greetd_ipc",
|
||||||
"i18n-embed",
|
"i18n-embed",
|
||||||
|
|
@ -2253,16 +2252,6 @@ dependencies = [
|
||||||
"xdg 2.5.2",
|
"xdg 2.5.2",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "freedesktop_entry_parser"
|
|
||||||
version = "1.3.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "db9c27b72f19a99a895f8ca89e2d26e4ef31013376e56fdafef697627306c3e4"
|
|
||||||
dependencies = [
|
|
||||||
"nom",
|
|
||||||
"thiserror 1.0.69",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "fsevent-sys"
|
name = "fsevent-sys"
|
||||||
version = "4.1.0"
|
version = "4.1.0"
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,6 @@ cosmic-config = { workspace = true, features = ["calloop", "macro"] }
|
||||||
cosmic-greeter-config.workspace = true
|
cosmic-greeter-config.workspace = true
|
||||||
cosmic-greeter-daemon = { path = "daemon" }
|
cosmic-greeter-daemon = { path = "daemon" }
|
||||||
dirs = "6"
|
dirs = "6"
|
||||||
freedesktop_entry_parser = "1.3.0"
|
|
||||||
libcosmic = { workspace = true, features = [
|
libcosmic = { workspace = true, features = [
|
||||||
"autosize",
|
"autosize",
|
||||||
"winit",
|
"winit",
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,7 @@ use cosmic::{
|
||||||
};
|
};
|
||||||
use cosmic::{
|
use cosmic::{
|
||||||
cosmic_theme::{self, CosmicPalette},
|
cosmic_theme::{self, CosmicPalette},
|
||||||
|
desktop::fde::{DesktopEntry, get_languages_from_env},
|
||||||
surface,
|
surface,
|
||||||
};
|
};
|
||||||
use cosmic_greeter_config::Config as CosmicGreeterConfig;
|
use cosmic_greeter_config::Config as CosmicGreeterConfig;
|
||||||
|
|
@ -186,6 +187,7 @@ pub fn main() -> Result<(), Box<dyn Error>> {
|
||||||
|
|
||||||
let sessions = {
|
let sessions = {
|
||||||
let mut sessions = HashMap::new();
|
let mut sessions = HashMap::new();
|
||||||
|
let locales = get_languages_from_env();
|
||||||
for (session_dir, session_type) in session_dirs {
|
for (session_dir, session_type) in session_dirs {
|
||||||
let read_dir = match fs::read_dir(&session_dir) {
|
let read_dir = match fs::read_dir(&session_dir) {
|
||||||
Ok(ok) => ok,
|
Ok(ok) => ok,
|
||||||
|
|
@ -212,7 +214,7 @@ pub fn main() -> Result<(), Box<dyn Error>> {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let entry = match freedesktop_entry_parser::parse_entry(dir_entry.path()) {
|
let entry = match DesktopEntry::from_path(dir_entry.path(), Some(&locales)) {
|
||||||
Ok(ok) => ok,
|
Ok(ok) => ok,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
tracing::warn!(
|
tracing::warn!(
|
||||||
|
|
@ -224,7 +226,7 @@ pub fn main() -> Result<(), Box<dyn Error>> {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let name = match entry.section("Desktop Entry").attr("Name") {
|
let name = match entry.name(&locales) {
|
||||||
Some(some) => some,
|
Some(some) => some,
|
||||||
None => {
|
None => {
|
||||||
tracing::warn!(
|
tracing::warn!(
|
||||||
|
|
@ -235,7 +237,7 @@ pub fn main() -> Result<(), Box<dyn Error>> {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let exec = match entry.section("Desktop Entry").attr("Exec") {
|
let exec = match entry.exec() {
|
||||||
Some(some) => some,
|
Some(some) => some,
|
||||||
None => {
|
None => {
|
||||||
tracing::warn!(
|
tracing::warn!(
|
||||||
|
|
@ -259,7 +261,11 @@ pub fn main() -> Result<(), Box<dyn Error>> {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Some(desktop_names) = entry.section("Desktop Entry").attr("DesktopNames") {
|
if let Some(desktop_names) = entry
|
||||||
|
.groups
|
||||||
|
.desktop_entry()
|
||||||
|
.and_then(|g| g.entry("DesktopNames"))
|
||||||
|
{
|
||||||
env.push(format!("XDG_CURRENT_DESKTOP={desktop_names}"));
|
env.push(format!("XDG_CURRENT_DESKTOP={desktop_names}"));
|
||||||
if let Some(name) = desktop_names.split(':').next() {
|
if let Some(name) = desktop_names.split(':').next() {
|
||||||
env.push(format!("XDG_SESSION_DESKTOP={name}"));
|
env.push(format!("XDG_SESSION_DESKTOP={name}"));
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue