Support running games on Asahi Linux
In Asahi Linux, since the host operates with 16K pages, x86_64 software needs to run in a 4K page microVM managed by muvm [1]. In practice, this means faugus-launcher can normally on the host, but faugus-run needs to run through muvm to ensure it operates in within the context of the microVM. This can be easily achieved by having faugus-run to re-exec itself under muvm when running under Asahi Linux. This doesn't have an impact on non-Asahi systems, other than the cost of checking the DT to identify the machine type which should be unnoticiable. [1] https://docs.fedoraproject.org/en-US/fedora-asahi-remix/x86-support/ Signed-off-by: Sergio Lopez <slp@sinrega.org>
This commit is contained in:
@@ -10,6 +10,7 @@ import time
|
|||||||
import shlex
|
import shlex
|
||||||
import gettext
|
import gettext
|
||||||
import signal
|
import signal
|
||||||
|
import shutil
|
||||||
|
|
||||||
gi.require_version("Gtk", "3.0")
|
gi.require_version("Gtk", "3.0")
|
||||||
|
|
||||||
@@ -798,7 +799,31 @@ def update_games_and_config():
|
|||||||
if changed:
|
if changed:
|
||||||
config_path.write_text("\n".join(new_lines) + "\n", encoding="utf-8")
|
config_path.write_text("\n".join(new_lines) + "\n", encoding="utf-8")
|
||||||
|
|
||||||
|
def is_apple_silicon():
|
||||||
|
path = "/proc/device-tree/compatible"
|
||||||
|
|
||||||
|
if not os.path.exists(path):
|
||||||
|
return False
|
||||||
|
|
||||||
|
try:
|
||||||
|
with open(path, "rb") as f:
|
||||||
|
dtcompat = f.read().decode('utf-8', errors='ignore')
|
||||||
|
|
||||||
|
if "apple,arm-platform" in dtcompat:
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
return False
|
||||||
|
except:
|
||||||
|
return False
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
if is_apple_silicon() and 'FAUGUS_MUVM' not in os.environ:
|
||||||
|
muvm_path = shutil.which('muvm')
|
||||||
|
if muvm_path:
|
||||||
|
env = os.environ.copy()
|
||||||
|
args = [muvm_path, "-i", "-e", "FAUGUS_MUVM=1", sys.executable, os.path.abspath(__file__)]
|
||||||
|
os.execvpe(muvm_path, args + sys.argv[1:], env)
|
||||||
|
|
||||||
apply_dark_theme()
|
apply_dark_theme()
|
||||||
update_games_and_config()
|
update_games_and_config()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user