flatpak-spawn - Linux


Overview

flatpak-spawn executes a specified executable inside a given Flatpak runtime environment. It allows users to run applications designed for a particular Flatpak without directly accessing the runtime’s graphical user interface or package manager.

Syntax

flatpak-spawn [options] -- [executable] [arguments...]

Options/Flags

  • –app-id: Specify the Flatpak application ID whose runtime should be used.
  • –bwrap-mountns: Use the bwrap tool to mount the namespace.
  • –env: Set an environment variable for the runtime environment.
  • –fake-home-dir: Simulate the user’s home directory within the runtime.
  • –help: Display help information.
  • –version: Display version information.

Examples

  • Run the gedit application in the org.gnome.gedit Flatpak runtime:
flatpak-spawn org.gnome.gedit gedit
  • Run the firefox browser using the environment variable DISPLAY:
flatpak-spawn --env=DISPLAY=:0 org.mozilla.firefox firefox

Common Issues

  • File permissions: Ensure that the files and directories within the Flatpak runtime have appropriate permissions for the user running the command.
  • Flatpak not installed: The flatpak command should be installed before using flatpak-spawn.

Integration

  • Flatpak-Builder: Use flatpak-spawn to run test applications during Flatpak package building.
  • Shell scripts: Embed flatpak-spawn in shell scripts to run commands in a specific Flatpak runtime environment.

Related Commands

  • flatpak: Manage Flatpak packages and runtimes.
  • bwrap: A utility for executing commands in a sandboxed user namespace.
  • unshare: A lower-level command for creating new namespaces.