clan-core/pkgs/clan-cli/clan_cli/flatpak.py
a-kenji 9bb4c8d094
All checks were successful
checks / check-links (pull_request) Successful in 14s
checks / checks-impure (pull_request) Successful in 1m50s
checks / checks (pull_request) Successful in 4m17s
clan-cli: add a check for the flatpak sandbox
Allows for differentiation between sandbox and non sandbox usage.
2024-04-02 12:19:48 +02:00

17 lines
391 B
Python

import os
def is_flatpak() -> bool:
"""Check if the current process is running inside a flatpak sandbox."""
# FLATPAK_ID environment variable check
flatpak_env = "FLATPAK_ID" in os.environ
flatpak_file = False
try:
with open("/.flatpak-info"):
flatpak_file = True
except FileNotFoundError:
pass
return flatpak_env and flatpak_file