diff --git a/sims/modules/launcher/apps.py b/sims/modules/launcher/apps.py index de63d40..c98d3a7 100644 --- a/sims/modules/launcher/apps.py +++ b/sims/modules/launcher/apps.py @@ -45,13 +45,27 @@ 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. + # Launch in a transient systemd --user scope so the app gets its own + # cgroup instead of inheriting sims.service's. start_new_session alone + # only changes POSIX session/pgid; systemd tracks units by cgroup and + # would kill children with sims on stop (default KillMode=control-group). 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) + subprocess.Popen( + [ + "systemd-run", + "--quiet", + "--user", + "--scope", + "--collect", + "--", + *argv, + ], + start_new_session=True, + ) return item.launch()