Skip to content

Instantly share code, notes, and snippets.

@itsmaxymoo
Last active June 19, 2024 20:11
Show Gist options
  • Save itsmaxymoo/3ffd38ed8f4d896e67e7c5af25b40173 to your computer and use it in GitHub Desktop.
Save itsmaxymoo/3ffd38ed8f4d896e67e7c5af25b40173 to your computer and use it in GitHub Desktop.
Script to create a desktop file for the official Minecraft launcher
#!/bin/python3
# ------------------------------------
# For easy execution, run the command:
# curl https://gist.githubusercontent.com/itsmaxymoo/3ffd38ed8f4d896e67e7c5af25b40173/raw | python3 -
# ------------------------------------
import os
import sys
HOME_DIR = os.path.expanduser("~")
DESKTOP_FILE_PATH = os.path.join(
HOME_DIR,
".local",
"share",
"applications",
"minecraft-launcher.desktop"
)
MC_LAUNCHER_DIR = os.path.join(
HOME_DIR,
".minecraft",
"launcher"
)
MC_LAUNCHER_EXEC = os.path.join(
MC_LAUNCHER_DIR,
"minecraft-launcher"
)
MC_LAUNCHER_ICON = os.path.join(
MC_LAUNCHER_DIR,
"icons",
"minecraft256.png"
)
DESKTOP_FILE_CONTENT = """[Desktop Entry]
Type=Application
Version=1.0
Name=Minecraft Launcher
Comment=Official Minecraft Launcher
Exec={exec}
# Swap the commented line to use your icon theme's Minecraft icon
Icon={icon}
# Icon=minecraft
Terminal=false
Categories=Game;Application;
StartupWMClass=minecraft-launcher
""".format(
exec=MC_LAUNCHER_EXEC,
icon=MC_LAUNCHER_ICON
)
if os.path.exists(DESKTOP_FILE_PATH):
print("File", DESKTOP_FILE_PATH, "already exists. Aborting...")
sys.exit(1)
desktop_file_writer = open(DESKTOP_FILE_PATH, "w")
desktop_file_writer.write(DESKTOP_FILE_CONTENT)
desktop_file_writer.close()
print("Created desktop file at", DESKTOP_FILE_PATH)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment