From 421c2812e30135452d99816d1018e2ba676df4f9 Mon Sep 17 00:00:00 2001 From: Faugus <112667550+Faugus@users.noreply.github.com> Date: Thu, 7 Nov 2024 13:31:12 -0300 Subject: [PATCH] Improved path managing --- faugus-launcher.py | 49 ++++++++++++++++++++++++---------------------- 1 file changed, 26 insertions(+), 23 deletions(-) diff --git a/faugus-launcher.py b/faugus-launcher.py index 298fd9b..2826eb8 100644 --- a/faugus-launcher.py +++ b/faugus-launcher.py @@ -25,6 +25,9 @@ share_dir = os.getenv('XDG_DATA_HOME', os.path.expanduser('~/.local/share')) app_dir = f'{share_dir}/applications' faugus_png = "/usr/share/icons/faugus-launcher.png" +faugus_run = "/usr/bin/faugus-run" +faugus_proton_manager = "/usr/bin/faugus-proton-manager" +umu_run = "/usr/bin/umu-run" def get_desktop_dir(): try: @@ -496,7 +499,7 @@ def on_button_play_clicked(self, widget): command_parts.append(launch_arguments) # Add the fixed command and remaining arguments - command_parts.append('"/usr/bin/umu-run"') + command_parts.append(f'"{umu_run}"') if path: command_parts.append(f'"{path}"') if game_arguments: @@ -507,7 +510,7 @@ def on_button_play_clicked(self, widget): print(command) # faugus-run path - faugus_run_path = "/usr/bin/faugus-run" + faugus_run_path = faugus_run # Launch the game with subprocess @@ -861,7 +864,7 @@ def add_shortcut(self, game, shortcut_state, icon_temp, icon_final): command_parts.append(launch_arguments) # Add the fixed command and remaining arguments - command_parts.append("'/usr/bin/umu-run'") + command_parts.append(f"'{umu_run}'") if path: command_parts.append(f"'{path}'") if game_arguments: @@ -873,7 +876,7 @@ def add_shortcut(self, game, shortcut_state, icon_temp, icon_final): # Create a .desktop file desktop_file_content = f"""[Desktop Entry] Name={game.title} - Exec=/usr/bin/faugus-run "{command}" + Exec={faugus_run} "{command}" Icon={new_icon_path} Type=Application Categories=Game; @@ -1298,7 +1301,7 @@ def __init__(self, parent): def on_button_proton_manager_clicked(self, widget): self.set_sensitive(False) - proton_manager = "/usr/bin/faugus-proton-manager" + proton_manager = faugus_proton_manager def run_command(): process = subprocess.Popen([sys.executable, proton_manager]) process.wait() @@ -1412,13 +1415,13 @@ def on_button_run_default_clicked(self, widget): command_parts.append(f'GAMEID=default') if runner: command_parts.append(f'PROTONPATH={runner}') - command_parts.append(f'"/usr/bin/umu-run" "{file_run}"') + command_parts.append(f'"{umu_run}" "{file_run}"') else: if file_run: command_parts.append(f'GAMEID=default') if runner: command_parts.append(f'PROTONPATH={runner}') - command_parts.append(f'"/usr/bin/umu-run" regedit "{file_run}"') + command_parts.append(f'"{umu_run}" regedit "{file_run}"') # Join all parts into a single command command = ' '.join(command_parts) @@ -1426,7 +1429,7 @@ def on_button_run_default_clicked(self, widget): print(command) # faugus-run path - faugus_run_path = "/usr/bin/faugus-run" + faugus_run_path = faugus_run def run_command(): process = subprocess.Popen([sys.executable, faugus_run_path, command, "winecfg"]) @@ -1479,7 +1482,7 @@ def on_button_winecfg_default_clicked(self, widget): command_parts.append(f'PROTONPATH={runner}') # Add the fixed command and remaining arguments - command_parts.append('"/usr/bin/umu-run"') + command_parts.append(f'"{umu_run}"') command_parts.append('"winecfg"') # Join all parts into a single command @@ -1488,7 +1491,7 @@ def on_button_winecfg_default_clicked(self, widget): print(command) # faugus-run path - faugus_run_path = "/usr/bin/faugus-run" + faugus_run_path = faugus_run def run_command(): process = subprocess.Popen([sys.executable, faugus_run_path, command, "winecfg"]) @@ -1538,7 +1541,7 @@ def on_button_winetricks_default_clicked(self, widget): command_parts.append(f'PROTONPATH={runner}') # Add the fixed command and remaining arguments - command_parts.append('"/usr/bin/umu-run"') + command_parts.append(f'"{umu_run}"') command_parts.append('""') # Join all parts into a single command @@ -1547,7 +1550,7 @@ def on_button_winetricks_default_clicked(self, widget): print(command) # faugus-run path - faugus_run_path = "/usr/bin/faugus-run" + faugus_run_path = faugus_run def run_command(): process = subprocess.Popen([sys.executable, faugus_run_path, command, "winetricks"]) @@ -2121,7 +2124,7 @@ def on_button_run_clicked(self, widget): command_parts.append(f'GAMEID={title_formatted}') if runner: command_parts.append(f'PROTONPATH={runner}') - command_parts.append(f'"/usr/bin/umu-run" "{file_run}"') + command_parts.append(f'"{umu_run}" "{file_run}"') else: if prefix: command_parts.append(f'WINEPREFIX={prefix}') @@ -2129,7 +2132,7 @@ def on_button_run_clicked(self, widget): command_parts.append(f'GAMEID={title_formatted}') if runner: command_parts.append(f'PROTONPATH={runner}') - command_parts.append(f'"/usr/bin/umu-run" regedit "{file_run}"') + command_parts.append(f'"{umu_run}" regedit "{file_run}"') # Join all parts into a single command command = ' '.join(command_parts) @@ -2137,7 +2140,7 @@ def on_button_run_clicked(self, widget): print(command) # faugus-run path - faugus_run_path = "/usr/bin/faugus-run" + faugus_run_path = faugus_run def run_command(): process = subprocess.Popen([sys.executable, faugus_run_path, command, "winecfg"]) @@ -2353,7 +2356,7 @@ def on_button_winecfg_clicked(self, widget): command_parts.append(f'PROTONPATH={runner}') # Add the fixed command and remaining arguments - command_parts.append('"/usr/bin/umu-run"') + command_parts.append(f'"{umu_run}"') command_parts.append('"winecfg"') # Join all parts into a single command @@ -2362,7 +2365,7 @@ def on_button_winecfg_clicked(self, widget): print(command) # faugus-run path - faugus_run_path = "/usr/bin/faugus-run" + faugus_run_path = faugus_run def run_command(): process = subprocess.Popen([sys.executable, faugus_run_path, command, "winecfg"]) @@ -2408,7 +2411,7 @@ def on_button_winetricks_clicked(self, widget): command_parts.append(f'PROTONPATH={runner}') # Add the fixed command and remaining arguments - command_parts.append('"/usr/bin/umu-run"') + command_parts.append(f'"{umu_run}"') command_parts.append('""') # Join all parts into a single command @@ -2417,7 +2420,7 @@ def on_button_winetricks_clicked(self, widget): print(command) # faugus-run path - faugus_run_path = "/usr/bin/faugus-run" + faugus_run_path = faugus_run def run_command(): process = subprocess.Popen([sys.executable, faugus_run_path, command, "winetricks"]) @@ -2938,7 +2941,7 @@ def on_ok_clicked(self, widget): command_parts.append(launch_arguments) # Add the fixed command and remaining arguments - command_parts.append("'/usr/bin/umu-run'") + command_parts.append(f"'{umu_run}'") if self.file_path: command_parts.append(f"'{self.file_path}'") if game_arguments: @@ -2950,7 +2953,7 @@ def on_ok_clicked(self, widget): # Create a .desktop file desktop_file_content = f"""[Desktop Entry] Name={title} - Exec=/usr/bin/faugus-run "{command}" + Exec={faugus_run} "{command}" Icon={new_icon_path} Type=Application Categories=Game; @@ -3139,7 +3142,7 @@ def run_file(file_path): # Define paths prefix_path = os.path.expanduser(f"{default_prefix}/default") - faugus_run_path = "/usr/bin/faugus-run" + faugus_run_path = faugus_run if not file_path.endswith(".reg"): mangohud_enabled = os.path.exists("/usr/bin/mangohud") @@ -3168,7 +3171,7 @@ def run_file(file_path): command_parts.append(gamemode) # Add the fixed command and remaining arguments - command_parts.append('"/usr/bin/umu-run"') + command_parts.append(f'"{umu_run}"') if file_path.endswith(".reg"): command_parts.append(f'regedit "{file_path}"') else: