Skip to content

Commit

Permalink
Improved path managing
Browse files Browse the repository at this point in the history
  • Loading branch information
Faugus authored Nov 7, 2024
1 parent a492ab2 commit 421c281
Showing 1 changed file with 26 additions and 23 deletions.
49 changes: 26 additions & 23 deletions faugus-launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand All @@ -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
Expand Down Expand Up @@ -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:
Expand All @@ -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;
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -1412,21 +1415,21 @@ 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)

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"])
Expand Down Expand Up @@ -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
Expand All @@ -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"])
Expand Down Expand Up @@ -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
Expand All @@ -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"])
Expand Down Expand Up @@ -2121,23 +2124,23 @@ 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}')
if title_formatted:
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)

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"])
Expand Down Expand Up @@ -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
Expand All @@ -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"])
Expand Down Expand Up @@ -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
Expand All @@ -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"])
Expand Down Expand Up @@ -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:
Expand All @@ -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;
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 421c281

Please sign in to comment.