[cli/core] Add support for launching games with a wrapper

This commit is contained in:
derrod 2020-05-20 12:49:51 +02:00
parent c904bbfa19
commit 0d6bcf5950
2 changed files with 9 additions and 2 deletions

View file

@ -372,7 +372,7 @@ class LegendaryCLI:
params, cwd, env = self.core.get_launch_parameters(app_name=app_name, offline=args.offline,
extra_args=extra, user=args.user_name_override,
wine_bin=args.wine_bin, wine_pfx=args.wine_pfx,
language=args.language)
language=args.language, wrapper=args.wrapper)
logger.info(f'Launching {app_name}...')
if args.dry_run:
@ -771,6 +771,9 @@ def main():
help='Print the command line that would have been used to launch the game and exit')
launch_parser.add_argument('--language', dest='language', action='store', metavar='<two letter language code>',
help='Override language for game launch (defaults to system settings)')
launch_parser.add_argument('--wrapper', dest='wrapper', action='store', metavar='<wrapper command>',
help='Wrapper command to launch game with')
if os.name != 'nt':
launch_parser.add_argument('--wine', dest='wine_bin', action='store', metavar='<wine binary>',
default=os.environ.get('LGDRY_WINE_BINARY', None),

View file

@ -230,7 +230,8 @@ class LegendaryCore:
def get_launch_parameters(self, app_name: str, offline: bool = False,
user: str = None, extra_args: list = None,
wine_bin: str = None, wine_pfx: str = None,
language: str = None) -> (list, str, dict):
language: str = None, wrapper: str = None
) -> (list, str, dict):
install = self.lgd.get_installed_game(app_name)
game = self.lgd.get_game_meta(app_name)
@ -251,6 +252,9 @@ class LegendaryCore:
params = []
if wrapper := self.lgd.config.get(app_name, 'wrapper', fallback=wrapper):
params.extend(shlex.split(wrapper))
if os.name != 'nt':
if not wine_bin:
# check if there's a default override