Skip to content

Instantly share code, notes, and snippets.

@Encritary
Created December 16, 2022 12:34
Show Gist options
  • Save Encritary/98cb68c3d00709b4d2f92a3d9c948ecd to your computer and use it in GitHub Desktop.
Save Encritary/98cb68c3d00709b4d2f92a3d9c948ecd to your computer and use it in GitHub Desktop.
A script to launch Minecraft Linux Launcher directly, bypassing the launcher UI
#!/usr/bin/python3
import os, sys, subprocess, signal
LAUNCHER_DATA = os.path.expanduser('~') + '/.local/share/mcpelauncher/'
USAGE = "Usage: mclaunch.py <version> [x32/x64 (default: x64)]"
if not (2 <= len(sys.argv) <= 3):
print(USAGE)
exit(1)
ver = sys.argv[1]
arch = sys.argv[2] if len(sys.argv) == 3 else 'x64'
if arch not in ['x32', 'x64']:
print(USAGE)
exit(1)
mc_path = LAUNCHER_DATA + 'versions/' + ver
if not os.path.isdir(mc_path):
print("Version", ver, "is not installed.")
exit(1)
proc = subprocess.Popen(['./Minecraft.AppImage', '--appimage-mount'], stdout=subprocess.PIPE)
try:
path = proc.stdout.readline().decode('utf-8').rstrip()
env = os.environ.copy()
env['LD_LIBRARY_PATH'] = path + '/usr/lib:/usr/lib'
mcbin = 'mcpelauncher-client' if arch == 'x64' else 'mcpelauncher-client32'
subprocess.run([path + '/usr/bin/' + mcbin, '-dg', mc_path], env=env)
except KeyboardInterrupt:
pass
finally:
proc.send_signal(signal.SIGINT)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment