freedesktop-apps

Crates.iofreedesktop-apps
lib.rsfreedesktop-apps
version0.0.3
created_at2025-09-16 01:09:15.85866+00
updated_at2025-09-23 03:53:11.571246+00
descriptionRust implementations of the freedesktop standards
homepagehttps://github.com/javif89/freedesktop
repositoryhttps://github.com/javif89/freedesktop
max_upload_size
id1840753
size89,198
Javier Feliz (javif89)

documentation

README

freedesktop-apps

Parse and execute desktop applications according to the freedesktop Desktop Entry Specification.

Features

  • Desktop Entry parsing - Robust parsing of .desktop files
  • Application execution - Safe launching with field code expansion
  • Localization support - Proper locale fallback for names and descriptions
  • Terminal applications - Automatic terminal detection and wrapping
  • Spec-compliant - Follows Desktop Entry Specification v1.5

Usage

Basic Application Discovery

use freedesktop_apps::ApplicationEntry;

// List all installed applications
for app in ApplicationEntry::all() {
    if app.should_show() {
        println!("{}: {}", app.id().unwrap(), app.name().unwrap());
    }
}

Application Information

let app = ApplicationEntry::try_from_path("/usr/share/applications/firefox.desktop")?;

println!("Name: {}", app.name().unwrap());
println!("Description: {}", app.comment().unwrap_or_default());
println!("Categories: {:?}", app.categories());
println!("Terminal app: {}", app.terminal());

Application Execution

// Execute with no arguments
app.execute()?;

// Execute with files
app.execute_with_files(&["/path/to/file.txt"])?;

// Execute with URLs  
app.execute_with_urls(&["https://example.com"])?;

Field Code Support

Supports all standard field codes:

  • %f - Single file
  • %F - Multiple files
  • %u - Single URL
  • %U - Multiple URLs
  • %i - Icon (--icon iconname)
  • %c - Translated name
  • %k - Desktop file location

Localization

// Get localized strings with fallback
let name = app.get_localized_string("Name", Some("es_ES"));
// Falls back: es_ES → es → default

Safety

  • Shell escaping - All arguments are properly escaped
  • Input validation - Malformed desktop files handled gracefully
  • Process isolation - Applications launched in detached processes
  • Error handling - Comprehensive error types for all failure modes
Commit count: 30

cargo fmt