#freedesktop #desktop #entry

freedesktop-desktop-entry

Freedesktop Desktop Entry Specification

1 unstable release

0.1.1 Jul 7, 2019
0.1.0 Jul 7, 2019

#4 in #freedesktop

Download history 25/week @ 2021-01-13 27/week @ 2021-01-20 37/week @ 2021-01-27 42/week @ 2021-02-03 154/week @ 2021-02-10 46/week @ 2021-02-17 47/week @ 2021-02-24 28/week @ 2021-03-03 26/week @ 2021-03-10 29/week @ 2021-03-17 37/week @ 2021-03-24 34/week @ 2021-03-31 40/week @ 2021-04-07 52/week @ 2021-04-14 28/week @ 2021-04-21 43/week @ 2021-04-28

199 downloads per month

MIT/Apache

9KB
160 lines

Freedesktop Desktop Entry Specification

This crate provides a library for efficiently generating valid desktop entries.

Example

This could be added to your build.rs, or as a workspace member:

use freedesktop_desktop_entry::{Application, DesktopEntry, DesktopType};
use std::{
    env,
    fs::File,
    io::Write,
    path::{Path, PathBuf},
};

const APPID: &str = "com.system76.Popsicle";

fn main() {
    let exec_path = Path::new("/usr").join("bin").join(APPID);
    let exec = exec_path.as_os_str().to_str().expect("prefix is not UTF-8");

    let mut desktop = File::create(["target/", APPID, ".desktop"].concat().as_str())
        .expect("failed to create desktop entry file");

    let entry = DesktopEntry::new(
        "Popsicle",
        APPID,
        DesktopType::Application(
            Application::new(&["System", "GTK"], exec)
                .keywords(&["usb", "flash" ,"drive", "image"])
                .startup_notify(),
        ),
    )
    .comment("Multiple USB image flasher")
    .generic_name("USB Flasher");

    desktop.write_all(entry.to_string().as_bytes());
}

Dependencies

~1.5MB
~41K SLoC