Merge branch 'sigmaSd-play_script'

This commit is contained in:
Mathieu Comandon 2018-11-04 14:05:02 -08:00
commit 5490660a49
2 changed files with 24 additions and 1 deletions

View file

@ -16,13 +16,15 @@ from lutris.runtime import RuntimeUpdater
from lutris.util import resources
from lutris.util.log import logger
from lutris.util.jobs import AsyncCall
from lutris.util.system import open_uri
from lutris.util.system import open_uri, path_exists
from lutris.util import http
from lutris.util import datapath
from lutris.util.steam import SteamWatcher
from lutris.util.dxvk import init_dxvk_versions
from lutris.thread import LutrisThread
from lutris.services import get_services_synced_at_startup, steam, xdg
from lutris.gui import dialogs
@ -125,6 +127,7 @@ class LutrisWindow(Gtk.ApplicationWindow):
('install', "Install", self.on_install_clicked),
('add', "Add manually", self.on_add_manually),
('configure', "Configure", self.on_edit_game_configuration),
('execute-script', "Execute script", self.on_execute_script_clicked),
('browse', "Browse files", self.on_browse_files),
('desktop-shortcut', "Create desktop shortcut",
self.create_desktop_shortcut),
@ -168,6 +171,7 @@ class LutrisWindow(Gtk.ApplicationWindow):
self.gui_needs_update = True
self.config_menu_first_access = True
def _init_actions(self):
Action = namedtuple('Action', ('callback', 'type', 'enabled', 'default', 'accel'))
@ -800,6 +804,18 @@ class LutrisWindow(Gtk.ApplicationWindow):
if game.is_installed:
dialog = EditGameConfigDialog(self, game, on_dialog_saved)
def on_execute_script_clicked(self, _widget):
"""Execute the game's associated script"""
game = Game(self.view.selected_game)
ondemand_command = game.runner.system_config.get(
"ondemand_command")
if path_exists(ondemand_command):
LutrisThread([ondemand_command],
include_processes=[
os.path.basename(ondemand_command)],
).start()
logger.info("Running %s in the background", ondemand_command)
def on_viewtype_state_change(self, action, val):
"""Callback to handle view type switch"""
action.set_state(val)

View file

@ -178,6 +178,13 @@ system_options = [ # pylint: disable=invalid-name
'help': ("Command line instructions to add in front of the game's "
"execution command.")
},
{
'option': 'ondemand_command',
'type': 'file',
'label': 'On-demand command',
'advanced': True,
'help': ("Script to execute from the game's contextual menu")
},
{
'option': 'prelaunch_command',
'type': 'file',