mirror of
https://github.com/SteamDeckHomebrew/decky-loader.git
synced 2026-07-11 21:11:58 +00:00
Additional touches
This commit is contained in:
+12
-1
@@ -394,9 +394,12 @@ async def get_tab_lambda(test) -> Tab:
|
|||||||
raise ValueError(f"Tab not found by lambda")
|
raise ValueError(f"Tab not found by lambda")
|
||||||
return tab
|
return tab
|
||||||
|
|
||||||
|
def tab_is_gamepadui(t: Tab) -> bool:
|
||||||
|
return "https://steamloopback.host/routes/" in t.url and (t.title == "Steam Shared Context presented by Valve™" or t.title == "Steam" or t.title == "SP")
|
||||||
|
|
||||||
async def get_gamepadui_tab() -> Tab:
|
async def get_gamepadui_tab() -> Tab:
|
||||||
tabs = await get_tabs()
|
tabs = await get_tabs()
|
||||||
tab = next((i for i in tabs if ("https://steamloopback.host/routes/" in i.url and (i.title == "Steam Shared Context presented by Valve™" or i.title == "Steam" or i.title == "SP"))), None)
|
tab = next((i for i in tabs if tab_is_gamepadui(i)), None)
|
||||||
if not tab:
|
if not tab:
|
||||||
raise ValueError(f"GamepadUI Tab not found")
|
raise ValueError(f"GamepadUI Tab not found")
|
||||||
return tab
|
return tab
|
||||||
@@ -405,3 +408,11 @@ async def inject_to_tab(tab_name, js, run_async=False):
|
|||||||
tab = await get_tab(tab_name)
|
tab = await get_tab(tab_name)
|
||||||
|
|
||||||
return await tab.evaluate_js(js, run_async)
|
return await tab.evaluate_js(js, run_async)
|
||||||
|
|
||||||
|
async def close_old_tabs():
|
||||||
|
tabs = await get_tabs()
|
||||||
|
for t in tabs:
|
||||||
|
if not t.title or (t.title != "Steam Shared Context presented by Valve™" and t.title != "Steam" and t.title != "SP"):
|
||||||
|
logger.debug("Closing tab: " + getattr(t, "title", "Untitled"))
|
||||||
|
await t.close()
|
||||||
|
await sleep(0.5)
|
||||||
|
|||||||
+2
-7
@@ -22,7 +22,7 @@ from helpers import (REMOTE_DEBUGGER_UNIT, csrf_middleware, get_csrf_token,
|
|||||||
get_home_path, get_homebrew_path, get_user,
|
get_home_path, get_homebrew_path, get_user,
|
||||||
get_user_group, set_user, set_user_group,
|
get_user_group, set_user, set_user_group,
|
||||||
stop_systemd_unit, start_systemd_unit)
|
stop_systemd_unit, start_systemd_unit)
|
||||||
from injector import get_gamepadui_tab, Tab, get_tabs
|
from injector import get_gamepadui_tab, Tab, get_tabs, close_old_tabs
|
||||||
from loader import Loader
|
from loader import Loader
|
||||||
from settings import SettingsManager
|
from settings import SettingsManager
|
||||||
from updater import Updater
|
from updater import Updater
|
||||||
@@ -170,12 +170,7 @@ class PluginManager:
|
|||||||
try:
|
try:
|
||||||
if first:
|
if first:
|
||||||
if await tab.has_global_var("deckyHasLoaded", False):
|
if await tab.has_global_var("deckyHasLoaded", False):
|
||||||
tabs = await get_tabs()
|
await close_old_tabs()
|
||||||
for t in tabs:
|
|
||||||
if not t.title or (t.title != "Steam" and t.title != "SP"):
|
|
||||||
logger.debug("Closing tab: " + getattr(t, "title", "Untitled"))
|
|
||||||
await t.close()
|
|
||||||
await sleep(0.5)
|
|
||||||
await tab.evaluate_js("try{if (window.deckyHasLoaded){setTimeout(() => location.reload(), 100)}else{window.deckyHasLoaded = true;(async()=>{try{while(!window.SP_REACT){await new Promise(r => setTimeout(r, 10))};await import('http://localhost:1337/frontend/index.js')}catch(e){console.error(e)};})();}}catch(e){console.error(e)}", False, False, False)
|
await tab.evaluate_js("try{if (window.deckyHasLoaded){setTimeout(() => location.reload(), 100)}else{window.deckyHasLoaded = true;(async()=>{try{while(!window.SP_REACT){await new Promise(r => setTimeout(r, 10))};await import('http://localhost:1337/frontend/index.js')}catch(e){console.error(e)};})();}}catch(e){console.error(e)}", False, False, False)
|
||||||
except:
|
except:
|
||||||
logger.info("Failed to inject JavaScript into tab\n" + format_exc())
|
logger.info("Failed to inject JavaScript into tab\n" + format_exc())
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ from asyncio import sleep, start_server, gather, open_connection
|
|||||||
from aiohttp import ClientSession, web
|
from aiohttp import ClientSession, web
|
||||||
|
|
||||||
from logging import getLogger
|
from logging import getLogger
|
||||||
from injector import inject_to_tab, get_gamepadui_tab
|
from injector import inject_to_tab, get_gamepadui_tab, close_old_tabs
|
||||||
import helpers
|
import helpers
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
@@ -251,6 +251,7 @@ class Utilities:
|
|||||||
self.logger.info("Connected to React DevTools, loading script")
|
self.logger.info("Connected to React DevTools, loading script")
|
||||||
tab = await get_gamepadui_tab()
|
tab = await get_gamepadui_tab()
|
||||||
# RDT needs to load before React itself to work.
|
# RDT needs to load before React itself to work.
|
||||||
|
await close_old_tabs()
|
||||||
result = await tab.reload_and_evaluate(script)
|
result = await tab.reload_and_evaluate(script)
|
||||||
self.logger.info(result)
|
self.logger.info(result)
|
||||||
|
|
||||||
@@ -262,5 +263,6 @@ class Utilities:
|
|||||||
self.logger.info("Disabling React DevTools")
|
self.logger.info("Disabling React DevTools")
|
||||||
tab = await get_gamepadui_tab()
|
tab = await get_gamepadui_tab()
|
||||||
self.rdt_script_id = None
|
self.rdt_script_id = None
|
||||||
await tab.evaluate_js("SteamClient.User.StartRestart();", False, True, False)
|
await close_old_tabs()
|
||||||
|
await tab.evaluate_js("location.reload();", False, True, False)
|
||||||
self.logger.info("React DevTools disabled")
|
self.logger.info("React DevTools disabled")
|
||||||
|
|||||||
@@ -6,12 +6,13 @@ i18next
|
|||||||
.use(initReactI18next)
|
.use(initReactI18next)
|
||||||
.use(Backend)
|
.use(Backend)
|
||||||
.init({
|
.init({
|
||||||
|
debug: true,
|
||||||
backend: {
|
backend: {
|
||||||
// path where resources get loaded from, or a function
|
// path where resources get loaded from, or a function
|
||||||
// returning a path:
|
// returning a path:
|
||||||
// function(lngs, namespaces) { return customPath; }
|
// function(lngs, namespaces) { return customPath; }
|
||||||
// the returned path will interpolate lng, ns if provided like giving a static path
|
// the returned path will interpolate lng, ns if provided like giving a static path
|
||||||
loadPath: '/locales/{{lng}}/{{ns}}.json',
|
loadPath: '/home/deck/homebrew/locales/{{lng}}/{{ns}}.json',
|
||||||
|
|
||||||
// path to post missing resources
|
// path to post missing resources
|
||||||
// addPath: '/locales/{{lng}}/{{ns}}.missing.json',
|
// addPath: '/locales/{{lng}}/{{ns}}.missing.json',
|
||||||
|
|||||||
Reference in New Issue
Block a user