Skip to content

Commit

Permalink
check if running in a flatpak sandbox before using flatpak-spawn
Browse files Browse the repository at this point in the history
  • Loading branch information
mijorus committed Aug 4, 2024
1 parent fa47ef0 commit fd65900
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/lib/terminal.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,17 @@
import threading
from typing import Callable, List, Union, Optional
import logging
import os

def is_flatpak():
return os.environ.get('FLATPAK_ID', False) != False

def host_sh(command: List[str], return_stderr=False, **kwargs) -> str:
try:
cmd = ['flatpak-spawn', '--host', *command]
cmd = [*command]

if is_flatpak():
cmd = ['flatpak-spawn', '--host', *cmd]

logging.debug(f'Running {cmd}')
output = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, **kwargs)
Expand Down

0 comments on commit fd65900

Please sign in to comment.