#linux #icons #freedesktop

freedesktop_entry_parser

A library for parsing FreeDesktop entry files

9 releases (4 stable)

1.1.2 May 7, 2021
1.1.1 Nov 8, 2020
1.1.0 Aug 11, 2020
1.0.0 Jul 25, 2020
0.1.0 Feb 28, 2020

#63 in Unix APIs

Download history 51/week @ 2021-02-25 49/week @ 2021-03-04 82/week @ 2021-03-11 78/week @ 2021-03-18 94/week @ 2021-03-25 60/week @ 2021-04-01 79/week @ 2021-04-08 108/week @ 2021-04-15 148/week @ 2021-04-22 92/week @ 2021-04-29 105/week @ 2021-05-06 92/week @ 2021-05-13 84/week @ 2021-05-20 72/week @ 2021-05-27 84/week @ 2021-06-03 78/week @ 2021-06-10

391 downloads per month
Used in 6 crates (5 directly)

MPL-2.0 license

37KB
809 lines

Freedesktop Entry Parser

crates.io docs.rs Minimum Supported Rust Version

A library for parsing FreeDesktop entry files in Rust. These files are used in the Desktop Entry, Icon Theme, and Systemd Unit file. They are similar to ini files but are distinct enough that an ini parse would not work.

Example Usage

As example input lets use the contents of sshd.service

[Unit]
Description=OpenSSH Daemon
Wants=sshdgenkeys.service
After=sshdgenkeys.service
After=network.target

[Service]
ExecStart=/usr/bin/sshd -D
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Restart=always

[Install]
WantedBy=multi-user.target

For example, to print the start command we could do this:

use freedesktop_entry_parser::parse_entry;

let entry = parse_entry("./test_data/sshd.service")?;
let start_cmd = entry
    .section("Service")
    .attr("ExecStart")
    .expect("Attribute doesn't exist");
println!("{}", start_cmd);

This prints /usr/bin/sshd -D

For more extensive documentation see docs.rs or generate the docs yourself by cloning the repo and running cargo doc. For more examples see the examples in the repo.

Contributing

Please send any and all patches, bugs, and questions to my public inbox ~zethra/public-inbox@lists.sr.ht or submit a ticket to the bug tracker if you feel so inclined todo.sr.ht/~zethra/linicon.

Dependencies

~1.1–1.7MB
~36K SLoC