fix steam dir detection

This commit is contained in:
Izalia Mae 2021-01-31 12:49:53 -05:00
parent 4aeaa61302
commit 1ac531b71f

View file

@ -1,4 +1,9 @@
#!/usr/bin/env python3
'''
A custom launcher for games that can't be run because of their own launchers
Just set the launch option to: /path/to/gamelaunch.py %command%
'''
import json, logging, signal, subprocess, sys
from PyQt5.QtCore import *
@ -11,17 +16,21 @@ from urllib.request import urlopen
if len(sys.argv) < 2:
args = ['/home/zoey/.steam/steam/steamapps/common/Proton 5.0/proton', 'waitforexitandrun', '/home/zoey/.steam/steam/steamapps/common/BorderlandsGOTYEnhanced/Binaries/Win64/Launcher.exe']
print('Missing arguments')
sys.exit()
else:
args = sys.argv[1:]
if 'debug' in sys.argv:
args = ['/home/zoey/.steam/steam/steamapps/common/Proton 5.0/proton', 'waitforexitandrun', '/home/zoey/.steam/steam/steamapps/common/BorderlandsGOTYEnhanced/Binaries/Win64/Launcher.exe']
else:
args = sys.argv[1:]
datapath = Path('~/.config/barkshark/proton-launcher').expanduser()
common = Path('~/.steam/steam/steamapps/common').expanduser()
configfile = datapath.joinpath('config.json')
gamelist = datapath.joinpath('games.json')
uifile = Path(__file__).resolve().parent.joinpath('gamelauncher.ui')
uifile = Path(__file__).resolve().parent.joinpath('gamelaunch.ui')
if not datapath.exists():
datapath.mkdir(parents=True, exist_ok=True)
@ -31,7 +40,7 @@ games = {
'default': {
'id': '0',
'code': 'none',
'name': 'n/a',
'name': 'Unknown Game',
'path': '.'
},
'BorderlandsGOTYEnhanced/Binaries/Win64/Launcher.exe': {
@ -66,6 +75,7 @@ class Launcher(QMainWindow):
super().__init__()
uic.loadUi(str(uifile), self)
self.app = app
self.common = None
self.game = self._get_game()
self.config = config.get(self.game['id'], {})
self.opts = {}
@ -76,7 +86,7 @@ class Launcher(QMainWindow):
}
self.command = ['/usr/bin/env'] + [f'{k}={v}' for k,v in self.env.items()] + args[:-1]
self.command.append(str(common.joinpath(self.game['path'])))
self.command.append(str(self.common.joinpath(self.game['path'])))
self.game_bl1 = self.game_borderlands
self.game_bl1e = self.game_borderlands
@ -160,9 +170,11 @@ class Launcher(QMainWindow):
def _get_game(self):
for arg in args:
if arg.endswith('.exe'):
self.game_bin = arg.replace(str(common) + '/', '')
game = games.get(self.game_bin, games['default'])
if arg.endswith('.exe') and 'common' in arg:
steamapps, game_bin = arg.split('/common/', 1)
self.common = Path(steamapps).joinpath('common')
game = games.get(game_bin, games['default'])
if game['name'] != 'default':
return game