"""Identifying gaming processes by their /proc cmdline. Process-name matching alone misses launchers run through an interpreter (``lutris`` is a Python script; several Minecraft launchers are ``java -jar``), so this reads argv and looks past the interpreter to the real program. """ from __future__ import annotations import os from pathlib import Path from typing import TYPE_CHECKING from steam_backlog_enforcer._counted_procs import key_by_name, load_counted_processes from steam_backlog_enforcer._total_block_launchers import LAUNCHER_PROCESS_NAMES from steam_backlog_enforcer.enforcer import ( get_pids_by_process_names, get_running_steam_game_pids, ) if TYPE_CHECKING: from steam_backlog_enforcer._playtime_state import PlaytimeRules _PROC = Path("/proc") # argv[0] basenames that tell us nothing: the real program is argv[1]. _INTERPRETERS = frozenset({"bash", "env", "java", "perl", "python", "python3", "sh"}) # An interpreter invocation needs at least `