Skip to content

Commit 07c9915

Browse files
committed
Refactor code structure for improved readability and maintainability
1 parent 33f6607 commit 07c9915

4 files changed

Lines changed: 28 additions & 1 deletion

File tree

installer.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import stat
77
import platform
88
import sys
9+
import winshell
910

1011
# === CONFIGURATION ===
1112
TARGET_DIR = os.path.expanduser("~/Documents/mc")
@@ -95,6 +96,31 @@ def main():
9596
inner_folder = get_inner_folder(extract_path)
9697
copy_and_replace(inner_folder, TARGET_DIR)
9798
create_run_scripts(TARGET_DIR)
99+
ICON = os.path.join(TARGET_DIR, "logo.ico")
100+
if platform.system() == "Windows":
101+
winshell.shortcut(
102+
os.path.join(TARGET_DIR, "run.bat"),
103+
TARGET_DIR,
104+
"Minecraft Launcher",
105+
ICON,
106+
"Minecraft Launcher"
107+
)
108+
elif platform.system() == "Linux":
109+
# Create a .desktop file for Linux
110+
desktop_file_path = os.path.join(os.path.expanduser("~/.local/share/applications"), "minecraft-launcher.desktop")
111+
with open(desktop_file_path, "w") as f:
112+
f.write(f"""[Desktop Entry]
113+
Name=Minecraft Launcher
114+
Exec={os.path.join(TARGET_DIR, "run.sh")}
115+
Type=Application
116+
Icon={ICON}
117+
Terminal=false
118+
StartupNotify=false
119+
""")
120+
print(f"Desktop entry created at {desktop_file_path}")
121+
else:
122+
print("Unsupported OS for creating shortcuts. Please create a shortcut manually.")
123+
print(f"Launcher installed to {TARGET_DIR}.")
98124

99125
if __name__ == "__main__":
100126
main()

logo.ico

33.3 KB
Binary file not shown.

logo.png

-50.4 KB
Binary file not shown.

requirements.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
requests
2-
pyinstaller
2+
pyinstaller
3+
winshell

0 commit comments

Comments
 (0)