Skip to main content

desktop-entry-lib

PyPI PyPI - Downloads PyPI - Python Version PyPI - License PyPI - Implementation Read the Docs

desktop-entry-lib allows reading and writing .desktop files according to the Desktop Entry Specification

import desktop_entry_lib


def write() -> None:
entry = desktop_entry_lib.DesktopEntry()

entry.Name.default_text = "My App"
entry.Comment.default_text = "A short description"
entry.Comment.translations["de"] = "A short german description"
entry.Type = "Application"
entry.Exec = "my-app"

entry.write_file("my_app.desktop")


def read() -> None:
entry = desktop_entry_lib.DesktopEntry.from_file("my_app.desktop")

print("Name: " + entry.Name.default_text)
print("Comment: " + entry.Comment.default_text)
print("German translation for Comment: " + entry.Comment.translations.get("de", "None"))
print("Type: " + entry.Type)
print("Exec: " + entry.Exec)


if __name__ == "__main__":
write()
read()

Features:

  • Fully static typed
  • No external dependencies
  • Full Documentation and Examples available
  • Support running inside a Flatpak
  • The whole lib is a single file
  • Supports PyPy

Read the documentation

Installation

You can install desktop-entry-lib from PyPI using pip:

pip install desktop-entry-lib

Documentation
Donation
Issues
Source