33 lines
698 B
Python
33 lines
698 B
Python
#!/usr/bin/python3
|
|
|
|
import os
|
|
|
|
|
|
def get_shortcut_icon_path(gameid, icons_dir, fallback_icon):
|
|
icon_png = os.path.join(icons_dir, f"{gameid}.png")
|
|
if os.path.exists(icon_png):
|
|
return icon_png
|
|
|
|
icon_ico = os.path.join(icons_dir, f"{gameid}.ico")
|
|
if os.path.exists(icon_ico):
|
|
return icon_ico
|
|
|
|
return fallback_icon
|
|
|
|
|
|
def build_desktop_entry(name, exec_command, icon_path, game_directory, startup_wm_class=""):
|
|
entry = [
|
|
"[Desktop Entry]",
|
|
f"Name={name}",
|
|
f"Exec={exec_command}",
|
|
f"Icon={icon_path}",
|
|
"Type=Application",
|
|
"Categories=Game;",
|
|
f"Path={game_directory}",
|
|
]
|
|
|
|
if startup_wm_class:
|
|
entry.append(f"StartupWMClass={startup_wm_class}")
|
|
|
|
return "\n".join(entry) + "\n"
|