Flatpak
==========================
desktop-entry-lib can be fully used inside a `Flatpak <https://flatpak.org>`_ 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 :code:`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:

.. code:: text

    --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, :func:`~desktop_entry_lib.__init__.DesktopEntryCollection.load_menu` will work as expected. If you also want to load the Icons, you need the following additional permissions.

.. code:: text

    --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 :code:`--talk-name=org.freedesktop.Flatpak` Permission. When you have this Permission, you can execute a Program on the Host with:

.. code:: python

    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.
