fix: start apps in subprocess
This commit is contained in:
@@ -1,3 +1,7 @@
|
||||
import re
|
||||
import shlex
|
||||
import subprocess
|
||||
|
||||
from fabric.utils.helpers import DesktopApp, get_desktop_applications
|
||||
from fabric.widgets.box import Box
|
||||
from fabric.widgets.image import Image
|
||||
@@ -9,6 +13,8 @@ from .base import FuzzyMenu
|
||||
|
||||
ICON_SIZE = 32
|
||||
|
||||
_FIELD_CODE_RE = re.compile(r"^%[fFuUickdDnNvm]$")
|
||||
|
||||
|
||||
class AppProvider:
|
||||
def items(self) -> list[DesktopApp]:
|
||||
@@ -39,6 +45,14 @@ class AppProvider:
|
||||
return Box(name="slot-box", orientation="h", spacing=10, children=children)
|
||||
|
||||
def activate(self, item: DesktopApp) -> None:
|
||||
# Detach from sims's session so apps survive sims shutdown.
|
||||
if item.command_line:
|
||||
argv = [
|
||||
t for t in shlex.split(item.command_line) if not _FIELD_CODE_RE.match(t)
|
||||
]
|
||||
if argv:
|
||||
subprocess.Popen(argv, start_new_session=True)
|
||||
return
|
||||
item.launch()
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user