Skip to content

Commit

Permalink
Update to reduce duplicate install attempts when loading the plugin f…
Browse files Browse the repository at this point in the history
…or a first-time install or version update, bump to version 0.2.6

Plugin._main no longer triggers an install, the UI will only trigger an checkInstallationStatus call once now
  • Loading branch information
wheaney committed Nov 1, 2023
1 parent 2bcee0b commit f624f73
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 13 deletions.
4 changes: 2 additions & 2 deletions bin/package
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ fi
read -s -p "Enter the password for deck@${deckip}: " password

# Use sshpass and scp to copy the file
output=$(sshpass -p "$password" scp "$zip_name" deck@"$deckip":/home/deck/Downloads)
output=$(sshpass -p "$password" scp -o PreferredAuthentications="password" "$zip_name" deck@"$deckip":/home/deck/Downloads)
echo "$output"

output=$(sshpass -p "$password" ssh deck@${deckip} "set -e; echo '${password}' | sudo -S chmod -R ug+rw /home/deck/homebrew/; mkdir -p /home/deck/homebrew/pluginloader; echo '${password}' | sudo -S rm -rf /home/deck/homebrew/plugins/$pluginname; echo '${password}' | sudo -S unzip /home/deck/Downloads/$zip_name -d /home/deck/homebrew/plugins; echo '${password}' | sudo -S systemctl restart plugin_loader")
output=$(sshpass -p "$password" ssh -o PreferredAuthentications="password" deck@${deckip} "set -e; echo '${password}' | sudo -S chmod -R ug+rw /home/deck/homebrew/; mkdir -p /home/deck/homebrew/pluginloader; echo '${password}' | sudo -S rm -rf /home/deck/homebrew/plugins/$pluginname; echo '${password}' | sudo -S unzip /home/deck/Downloads/$zip_name -d /home/deck/homebrew/plugins; echo '${password}' | sudo -S systemctl restart plugin_loader")
echo "$output"

if [ $? -ne 0 ]; then
Expand Down
23 changes: 19 additions & 4 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ async def is_driver_installed(self):
return False

async def install_driver(self):
decky_plugin.logger.info(f"Installing driver for plugin version {decky_plugin.DECKY_PLUGIN_VERSION}")
decky_plugin.logger.info(f"Installing breezy for plugin version {decky_plugin.DECKY_PLUGIN_VERSION}")

# Set the USER environment variable for this command
env_copy = os.environ.copy()
Expand All @@ -111,13 +111,12 @@ async def install_driver(self):
settings.setSetting(INSTALLED_VERSION_SETTING_KEY, decky_plugin.DECKY_PLUGIN_VERSION)
return True
except subprocess.CalledProcessError as exc:
decky_plugin.logger.error("Error running setup script", exc)
decky_plugin.logger.error(f"Error running setup script {exc}")
return False

# Asyncio-compatible long-running code, executed in a task when the plugin is loaded
async def _main(self):
if not await self.is_driver_installed(self):
await self.install_driver(self)
pass

# Function called first during the unload process, utilize this to handle your plugin being removed
async def _unload(self):
Expand All @@ -126,3 +125,19 @@ async def _unload(self):
# Migrations that should be performed before entering `_main()`.
async def _migration(self):
pass

async def _uninstall(self):
decky_plugin.logger.info(f"Uninstalling breezy for plugin version {decky_plugin.DECKY_PLUGIN_VERSION}")

# Set the USER environment variable for this command
env_copy = os.environ.copy()
env_copy["USER"] = decky_plugin.DECKY_USER

try:
subprocess.check_output([decky_plugin.DECKY_USER_HOME + "/bin/breezy_vulkan_uninstall"], stderr=subprocess.STDOUT, env=env_copy)
subprocess.check_output([decky_plugin.DECKY_USER_HOME + "/bin/xreal_driver_uninstall"], stderr=subprocess.STDOUT, env=env_copy)
settings.setSetting(INSTALLED_VERSION_SETTING_KEY, None)
return True
except subprocess.CalledProcessError as exc:
decky_plugin.logger.error(f"Error running uninstall script {exc}")
return False
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "decky-xrealAir",
"version": "0.2.5",
"version": "0.2.6",
"description": "Virtual display and head-tracking modes for the XREAL Air glasses",
"scripts": {
"build": "shx rm -rf dist && rollup -c",
Expand Down Expand Up @@ -54,13 +54,13 @@
"custom_remote_binary": [
{
"name": "breezy_vulkan_setup",
"url": "https://github.com/wheaney/breezy-desktop/releases/download/v0.1.1-beta/breezy_vulkan_setup",
"url": "https://github.com/wheaney/breezy-desktop/releases/download/v0.1.2-beta/breezy_vulkan_setup",
"sha256hash": "6d4c4d0cf4d88f05e5dab19b1c4a50378c6f712f31f48e50ae542e150892e5e3"
},
{
"name": "breezyVulkan.tar.gz",
"url": "https://github.com/wheaney/breezy-desktop/releases/download/v0.1.1-beta/breezyVulkan.tar.gz",
"sha256hash": "e8e68f70e86cc34e99b231aae7341c841abe2dcf45fc8430b99ea0f9c0b62499"
"url": "https://github.com/wheaney/breezy-desktop/releases/download/v0.1.2-beta/breezyVulkan.tar.gz",
"sha256hash": "3353d711404ee3956e281f00f8ba4f6b3c91e044c8956076152eb037c3661eb2"
}
]
}
7 changes: 4 additions & 3 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,11 @@ const Content: VFC<{ serverAPI: ServerAPI }> = ({serverAPI}) => {
}
}

// these asynchronous calls should execute ONLY one time, hence the empty array as the second argument
useEffect(() => {
if (!config) retrieveConfig().catch((err) => setError(err));
if (installationStatus == "checking") checkInstallation().catch((err) => setError(err));
});
retrieveConfig().catch((err) => setError(err));
checkInstallation().catch((err) => setError(err));
}, []);

const isDisabled = config?.disabled ?? false
const outputMode = config?.output_mode ?? 'mouse'
Expand Down

1 comment on commit f624f73

@wheaney
Copy link
Owner Author

@wheaney wheaney commented on f624f73 Nov 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uninstall callback will be unused until SteamDeckHomebrew/decky-loader#555 is merged

Please sign in to comment.