#freedesktop #icons #systemd-unit #ini-parser #linux

freedesktop_entry_parser

A library for parsing FreeDesktop entry files

11 releases (6 stable)

1.3.0 Feb 3, 2022
1.2.0 Jul 30, 2021
1.1.2 May 7, 2021
1.1.1 Nov 8, 2020
0.2.0 Mar 27, 2020

#132 in Unix APIs

Download history 2283/week @ 2024-07-04 2515/week @ 2024-07-11 2736/week @ 2024-07-18 3331/week @ 2024-07-25 2460/week @ 2024-08-01 4281/week @ 2024-08-08 2813/week @ 2024-08-15 3068/week @ 2024-08-22 2788/week @ 2024-08-29 2644/week @ 2024-09-05 2856/week @ 2024-09-12 3136/week @ 2024-09-19 3286/week @ 2024-09-26 4295/week @ 2024-10-03 3989/week @ 2024-10-10 4186/week @ 2024-10-17

16,437 downloads per month
Used in 17 crates (10 directly)

MPL-2.0 license

39KB
824 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.

MSRV Policy

The current minimum support rustc version is specified above in this readme. We reserve the right to change this on minor version increases, but we will try to keep it reasonable. Given that this library is feature complete, the MSVR will likely only change with our dependencies.

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.7MB
~35K SLoC