diff options
| -rw-r--r-- | .gitignore | 29 | ||||
| -rw-r--r-- | decky_client.py | 46 | ||||
| -rw-r--r-- | user_install_script.sh | 6 |
3 files changed, 72 insertions, 9 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..782e811 --- /dev/null +++ b/.gitignore @@ -0,0 +1,29 @@ +# Python +__pycache__/ +*.py[cod] +*$py.class +*.so +.Python +*.egg-info/ +dist/ +build/ +*.egg + +# Testing +.pytest_cache/ +.coverage +htmlcov/ + +# IDE +.vscode/ +.idea/ +*.swp +*.swo +*~ + +# OS +.DS_Store +Thumbs.db + +# Logs +*.log diff --git a/decky_client.py b/decky_client.py index 53f8037..597a9b3 100644 --- a/decky_client.py +++ b/decky_client.py @@ -17,6 +17,13 @@ EVENT = 3 # Default store URL DEFAULT_STORE_URL = "https://plugins.deckbrew.xyz/plugins" +# Store type mapping +STORE_TYPE_NAMES = { + 0: "default", + 1: "testing", + 2: "custom" +} + def log(*args: Any) -> None: """Print formatted logs to stderr.""" @@ -295,10 +302,21 @@ async def configure_store_url(store_url: str) -> None: token = await client.get_token() await client.connect(token) - log(f"Setting custom store URL: {store_url}") - await client.send(CALL, "utilities/settings/set", ["store_url", store_url]) + # First, set the store type to 2 (custom) + log(f"Setting store type to custom (2)...") + await client.send(CALL, "utilities/settings/set", ["store", 2]) + msg = await client.recv() + if msg is None: + raise RuntimeError("Connection closed by server") + + if msg.get("type") == ERROR: + log(f"Server error setting store type: {msg.get('error')}") + raise RuntimeError(f"Failed to set store type: {msg.get('error')}") + + log(f"Store type set to custom") - # Wait for reply + log(f"Setting custom store URL: {store_url}") + await client.send(CALL, "utilities/settings/set", ["store-url", store_url]) msg = await client.recv() if msg is None: raise RuntimeError("Connection closed by server") @@ -319,17 +337,33 @@ async def configure_store_url(store_url: str) -> None: async def get_store_url() -> str: - """Get the configured custom store URL from Decky settings.""" + """Get the configured custom store URL and type from Decky settings.""" client = DeckyClient() try: log(f"Connecting to Decky server at {client.host}:{client.port}...") token = await client.get_token() await client.connect(token) + # Get store type + log("Getting configured store type...") + await client.send(CALL, "utilities/settings/get", ["store", 0]) + + msg = await client.recv() + if msg is None: + raise RuntimeError("Connection closed by server") + + if msg.get("type") == REPLY: + store_type = msg.get('result') + store_type_name = STORE_TYPE_NAMES.get(store_type, f"unknown ({store_type})") + log(f"Current store type: {store_type_name}") + elif msg.get("type") == ERROR: + log(f"Server error: {msg.get('error')}") + raise RuntimeError(f"Failed to get store type: {msg.get('error')}") + + # Get store URL log("Getting configured store URL...") - await client.send(CALL, "utilities/settings/get", ["store_url", DEFAULT_STORE_URL]) + await client.send(CALL, "utilities/settings/get", ["store-url", DEFAULT_STORE_URL]) - # Wait for reply msg = await client.recv() if msg is None: raise RuntimeError("Connection closed by server") diff --git a/user_install_script.sh b/user_install_script.sh index 42bdd38..fac2146 100644 --- a/user_install_script.sh +++ b/user_install_script.sh @@ -69,13 +69,13 @@ if ! (cd /tmp && sha256sum -c decky_client.py.sha256); then exit 1 fi +# Configure the custom store URL first to ensure install requests go to the correct store +python3 "${decky_client}" configure-store "https://${DECKY_PLUGIN_MIRROR_HOST}/plugins" + # Install the plugin python3 "${decky_client}" install \ --store-url "https://${DECKY_PLUGIN_MIRROR_HOST}/plugins" \ --target-id "${DECKY_PLUGIN_TARGET_ID}" -# Configure the custom store URL for future use -python3 "${decky_client}" configure-store "https://${DECKY_PLUGIN_MIRROR_HOST}/plugins" - # Clean up rm -f "${decky_client}" "${decky_client_checksum}" |
