Flatpak - desktop-entry-lib 5.0 documentation

Skip to content
Back to top
View this page

# Flatpak

desktop-entry-lib can be fully used inside a Flatpak container. If you just want read/write Desktop Entries, there’s nothing you need to do.

## Loading Entries from them Menu

Please note that the `XDG_DATA_DIRS` Environment Variable from the Host is not available inside a Flatpak, so desktop-entry-lib will not find custom locations. The standard locations however are found. desktop-entry-lib detects when it runs inside a Flatpak and will use the default locations which are hardcoded. The Flatpak will need the following permissions to find all desktop entries:

    --filesystem=/var/lib/flatpak/exports/share/applications:ro
    --filesystem=xdg-data/flatpak/exports/share/applications:ro
    --filesystem=xdg-data/applications:ro
    --filesystem=/var/lib/flatpak/app:ro
    --filesystem=xdg-data/flatpak/app:ro
    --filesystem=host-etc:ro

After you grant this Permissions, `load_menu()` will work as expected. If you also want to load the Icons, you need the following additional permissions.

    --filesystem=/var/lib/flatpak/exports/share/icons:ro
    --filesystem=xdg-data/flatpak/exports/share/icons:ro

## Starting Programs

If you want to start a Program on the host, you need the `--talk-name=org.freedesktop.Flatpak` Permission. When you have this Permission, you can execute a Program on the Host with:

    entry = desktop_entry_lib.DesktopEntry.from_file("my_app.desktop")
    command = entry.get_command()
    subprocess.run(["flatpak-spawn", "--host"] + command, cwd=entry.get_working_directory())

If you want to open a File, please note that the Paths you have inside your Flatpak may differ from the Paths on your Host.