A library for parsing FreeDesktop entry files & systemd unit file
  • Rust 96.7%
  • Nix 3.1%
  • Shell 0.2%
Find a file
2025-12-20 00:16:25 -08:00
.woodpecker Add Woodpecker CI config 2025-10-17 02:16:50 -04:00
contrib Update _incr_version script 2024-10-06 00:30:36 -04:00
examples Support duplicate sections and keys in high level API 2025-10-01 20:47:56 -04:00
fuzz Add fuzzing setup 2024-10-03 21:24:01 -04:00
src Fix typo in parse error message 2025-12-20 00:16:25 -08:00
test_data Rename test_data/systemd-example.txt to test_data/edge-cases.txt 2025-10-04 21:33:51 -04:00
.gitignore Add nix shell 2024-08-31 17:30:37 -04:00
Cargo.toml Bump version to 2.0.1 2025-10-17 19:43:52 -04:00
flake.lock Update dev env to rust 1.90 2025-10-01 20:49:49 -04:00
flake.nix Change MSRV to 1.61.0 and add MSRV check 2024-09-30 20:54:21 -04:00
LICENSE Moved out of [linicon](https://git.sr.ht/~zethra/linicon) 2023-09-10 16:52:11 -04:00
msrv-shell.nix Increase MSRV to 1.65 2025-10-01 21:14:26 -04:00
nightly-shell.nix Remove miri from CI 2024-10-06 00:44:30 -04:00
README.md Remove move notice and add CI badge 2025-10-17 02:27:06 -04:00
rustfmt.toml Moved out of [linicon](https://git.sr.ht/~zethra/linicon) 2023-09-10 16:52:11 -04:00
shell.nix Add llvm-tools-preview for code coverage reports 2024-10-02 21:54:48 -04:00

Freedesktop Entry Parser

crates.io docs.rs Minimum Supported Rust Version CI Status

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

MSRV: 1.65.0

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

Issue and PR welcome! If you prefer to send me a patch instead of opening a PR feel free to send it to ~zethra/public-inbox@lists.sr.ht.