flatpak‐install - uhop/dotfiles GitHub Wiki

flatpak-install

Install flatpak packages, dispatching between --system and --user scopes with automatic deduplication.

Usage

flatpak-install [options] <package>...

Options

Option Description
--system Force system install (errors if not viable)
--user Force user install
--remote=REMOTE Flatpak remote to install from (default: flathub)
-n, --dry-run Show the plan without installing
--verbose Show per-package dispatch decisions
-y, --yes Assume yes to flatpak prompts
-v, --version Show version
-h, --help Show help

Dispatch logic

For each input package:

  1. Dedup. If flatpak info <pkg> already succeeds in either scope, the package is skipped. Dedup is cross-scope: if one user on a machine already installed Firefox system-wide, every other user sees it and skips.

  2. Scope choice. A single scope is chosen for all remaining packages:

    • system when the managed polkit rule at /usr/local/share/polkit-1/rules.d/90-flatpak-ssh.rules is deployed and the current user is in sudo or wheel — polkit handles the D-Bus authorization and the install works over SSH.
    • system when sudo -n true succeeds — the install is wrapped in sudo -n flatpak install --system ... so it bypasses polkit via root rather than tripping a polkit prompt that has nowhere to go over SSH.
    • user otherwise — no privileges required, installs into ~/.local/share/flatpak.
  3. Batch install. Remaining packages are installed in a single flatpak install call to the chosen scope.

--system or --user override the auto-decision; --system errors if no viable path exists.

Prerequisites

Examples

flatpak-install --dry-run org.mozilla.firefox com.github.tchx84.Flatseal
flatpak-install -y org.mozilla.firefox
flatpak-install --user org.videolan.VLC
flatpak-install --remote=my-remote org.example.App

Library

~/.local/libs/flatpak-install.sh is a sourceable bash library that exposes the probes separately:

  • flatpak_install::has_polkit_rule — 0 if the managed polkit rule file exists.
  • flatpak_install::in_sudo_group — 0 if the user is in sudo/wheel.
  • flatpak_install::can_sudo_nopasswd — 0 if sudo -n true succeeds.
  • flatpak_install::can_system — 0 if a --system install is viable non-interactively.
  • flatpak_install::system_needs_sudo — 0 if --system install must be wrapped in sudo (no polkit path).
  • flatpak_install::chosen_scope — echoes system or user.
  • flatpak_install::scope_of <pkg> — echoes system, user, or none.
  • flatpak_install::has_remote <remote> [system|user] — 0 if the remote is configured.

The library is pure bash and has no options.bash dependency; other scripts can source it directly.

⚠️ **GitHub.com Fallback** ⚠️