Compare commits

...

7 Commits

Author SHA1 Message Date
TrainDoctor 63b25bce85 All good, code was not modified to accomodate ints 2023-03-05 18:12:31 -08:00
TrainDoctor dd0bfb4821 Int is nice but it breaks plugins 2023-03-05 18:07:17 -08:00
TrainDoctor c1055b73bb Update logic for stub check 2023-03-05 16:37:57 -08:00
Jayden 3b59542ddd Expose USER_ID and DECKY_USER_ID to plugins (#389) 2023-03-05 16:28:21 -08:00
TrainDoctor 0dd0d9f4bd Add CI to automatically update plugin stub in template 2023-03-05 16:23:17 -08:00
geeksville 3e5404abdd fix #390 the plugin_directory argument to import_plugin was incorrect (#391) 2023-03-05 14:30:26 -08:00
Beebles 46abc5a266 Fix QAM And Toaster Injection for Mar 02 Beta (#388) 2023-03-01 20:20:31 -08:00
8 changed files with 92 additions and 11 deletions
+45
View File
@@ -0,0 +1,45 @@
name: Push Updated Plugin Stub to Template
on: push
jobs:
copy-stub:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@8230315d06ad95c617244d2f265d237a1682d445
with:
ref: ${{ github.sha }}
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Checkout
uses: actions/checkout@v2
- name: Is stub changed
id: changed-stub
run: |
STUB_CHANGED="false"
PATHS=(plugin plugin/decky_plugin.pyi)
SHA="${{ github.sha }}"
SHA_PREV=$(git rev-list --parents -n 1 $SHA)
FILES=$(git diff $SHA_PREV --name-only -- ${PATHS[@]} | jq -Rsc 'split("\n")[:-1] | join (",")')
if [[ "$FILES" == *"plugin/decky_plugin.pyi"* ]]; then
STUB_CHANGED="true"
echo "Stub has changed, pushing updated stub"
else
echo "Stub has not changed, exiting."
exit 0
fi
- name: Push updated stub
if: steps.changed-stub.outputs.has_changed == true
uses: dmnemec/copy_file_to_another_repo_action@bbebd3da22e4a37d04dca5f782edd5201cb97083
env:
API_TOKEN_GITHUB: ${{ secrets.GITHUB_TOKEN }}
with:
source_file: 'plugin/decky_plugin.pyi'
destination_repo: 'SteamDeckHomebrew/decky-plugin-template'
user_email: '11465594+TrainDoctor@users.noreply.github.com'
user_name: 'TrainDoctor'
commit_message: 'Updated template with latest plugin stub changes'
+10 -7
View File
@@ -42,7 +42,7 @@ class PluginBrowser:
return False
zip_file = ZipFile(zip)
zip_file.extractall(self.plugin_path)
plugin_dir = self.find_plugin_folder(name)
plugin_dir = path.join(self.plugin_path, self.find_plugin_folder(name))
code_chown = call(["chown", "-R", get_user()+":"+get_user_group(), plugin_dir])
code_chmod = call(["chmod", "-R", "555", plugin_dir])
if code_chown != 0 or code_chmod != 0:
@@ -92,6 +92,7 @@ class PluginBrowser:
return rv
"""Return the filename (only) for the specified plugin"""
def find_plugin_folder(self, name):
for folder in listdir(self.plugin_path):
try:
@@ -99,7 +100,7 @@ class PluginBrowser:
plugin = json.load(f)
if plugin['name'] == name:
return str(path.join(self.plugin_path, folder))
return folder
except:
logger.debug(f"skipping {folder}")
@@ -107,9 +108,10 @@ class PluginBrowser:
if self.loader.watcher:
self.loader.watcher.disabled = True
tab = await get_gamepadui_tab()
plugin_dir = path.join(self.plugin_path, self.find_plugin_folder(name))
try:
logger.info("uninstalling " + name)
logger.info(" at dir " + self.find_plugin_folder(name))
logger.info(" at dir " + plugin_dir)
logger.debug("calling frontend unload for %s" % str(name))
res = await tab.evaluate_js(f"DeckyPluginLoader.unloadPlugin('{name}')")
logger.debug("result of unload from UI: %s", res)
@@ -123,11 +125,11 @@ class PluginBrowser:
del self.plugins[name]
logger.debug("Plugin %s was removed from the dictionary", name)
logger.debug("removing files %s" % str(name))
rmtree(self.find_plugin_folder(name))
rmtree(plugin_dir)
except FileNotFoundError:
logger.warning(f"Plugin {name} not installed, skipping uninstallation")
except Exception as e:
logger.error(f"Plugin {name} in {self.find_plugin_folder(name)} was not uninstalled")
logger.error(f"Plugin {name} in {plugin_dir} was not uninstalled")
logger.error(f"Error at %s", exc_info=e)
if self.loader.watcher:
self.loader.watcher.disabled = False
@@ -160,7 +162,8 @@ class PluginBrowser:
logger.debug("Unzipping...")
ret = self._unzip_to_plugin_dir(res_zip, name, hash)
if ret:
plugin_dir = self.find_plugin_folder(name)
plugin_folder = self.find_plugin_folder(name)
plugin_dir = path.join(self.plugin_path, plugin_folder)
ret = await self._download_remote_binaries_for_plugin_with_name(plugin_dir)
if ret:
logger.info(f"Installed {name} (Version: {version})")
@@ -168,7 +171,7 @@ class PluginBrowser:
self.loader.plugins[name].stop()
self.loader.plugins.pop(name, None)
await sleep(1)
self.loader.import_plugin(path.join(plugin_dir, "main.py"), plugin_dir)
self.loader.import_plugin(path.join(plugin_dir, "main.py"), plugin_folder)
else:
logger.fatal(f"Failed Downloading Remote Binaries")
else:
+3 -1
View File
@@ -64,8 +64,10 @@ class PluginWrapper:
# export a bunch of environment variables to help plugin developers
environ["HOME"] = helpers.get_home_path("root" if "root" in self.flags else helpers.get_user())
environ["USER"] = "root" if "root" in self.flags else helpers.get_user()
environ["USER_ID"] = "0" if "root" in self.flags else helpers.get_user_id()
environ["DECKY_VERSION"] = helpers.get_loader_version()
environ["DECKY_USER"] = helpers.get_user()
environ["DECKY_USER"] = str(helpers.get_user())
environ["DECKY_USER_ID"] = str(helpers.get_user_id())
environ["DECKY_USER_HOME"] = helpers.get_home_path()
environ["DECKY_HOME"] = helpers.get_homebrew_path()
environ["DECKY_PLUGIN_SETTINGS_DIR"] = path.join(environ["DECKY_HOME"], "settings", self.plugin_directory)
+2 -2
View File
@@ -108,10 +108,10 @@ class Updater:
logger.debug("determining release type to find, branch is %i" % selectedBranch)
if selectedBranch == 0:
logger.debug("release type: release")
self.remoteVer = next(filter(lambda ver: ver["tag_name"].startswith("v") and not ver["prerelease"] and ver["tag_name"], remoteVersions), None)
self.remoteVer = next(filter(lambda ver: ver["tag_name"].startswith("v") and not ver["prerelease"] and not ver["tag_name"].find("-pre") > 0 and ver["tag_name"], remoteVersions), None)
elif selectedBranch == 1:
logger.debug("release type: pre-release")
self.remoteVer = next(filter(lambda ver: ver["prerelease"] and ver["tag_name"].startswith("v") and ver["tag_name"].find("-pre"), remoteVersions), None)
self.remoteVer = next(filter(lambda ver:ver["tag_name"].startswith("v"), remoteVersions), None)
else:
logger.error("release type: NOT FOUND")
raise ValueError("no valid branch found")
+1 -1
View File
@@ -35,7 +35,7 @@ class TabsHook extends Logger {
const tree = (document.getElementById('root') as any)._reactRootContainer._internalRoot.current;
let qAMRoot: any;
const findQAMRoot = (currentNode: any, iters: number): any => {
if (iters >= 55) {
if (iters >= 65) {
// currently 45
return null;
}
+1
View File
@@ -45,6 +45,7 @@ class Toaster extends Logger {
return null;
}
if (
currentNode?.memoizedProps?.className?.startsWith?.('gamepadtoasts_GamepadToastPlaceholder') ||
currentNode?.memoizedProps?.className?.startsWith?.('toastmanager_ToastPlaceholder') ||
currentNode?.memoizedProps?.className?.startsWith?.('toastmanager_ToastPopup')
) {
+15
View File
@@ -38,6 +38,14 @@ It would be `root` if `root` was specified in the plugin's flags otherwise the u
e.g.: `deck`
"""
USER_ID: int = int(os.getenv("USER_ID", default="-1"))
"""
The effective UID running the process.
Environment variable: `USER_ID`.
It would be `0` if `root` was specified in the plugin's flags otherwise the id of the user whose home decky resides in.
e.g.: `1000`
"""
DECKY_VERSION: str = os.getenv("DECKY_VERSION", default="")
"""
The version of the decky loader.
@@ -52,6 +60,13 @@ Environment variable: `DECKY_USER`.
e.g.: `deck`
"""
DECKY_USER_ID: int = int(os.getenv("DECKY_USER_ID", default="-1"))
"""
The UID of the user whose home decky resides in.
Environment variable: `DECKY_USER_ID`.
e.g.: `1000`
"""
DECKY_USER_HOME: str = os.getenv("DECKY_USER_HOME", default="")
"""
The home of the user where decky resides in.
+15
View File
@@ -36,6 +36,14 @@ It would be `root` if `root` was specified in the plugin's flags otherwise the u
e.g.: `deck`
"""
USER_ID: int
"""
The effective UID running the process.
Environment variable: `UID`.
It would be `0` if `root` was specified in the plugin's flags otherwise the id of the user whose home decky resides in.
e.g.: `1000`
"""
DECKY_VERSION: str
"""
The version of the decky loader.
@@ -50,6 +58,13 @@ Environment variable: `DECKY_USER`.
e.g.: `deck`
"""
DECKY_USER_ID: int
"""
The UID of the user whose home decky resides in.
Environment variable: `DECKY_USER_ID`.
e.g.: `1000`
"""
DECKY_USER_HOME: str
"""
The home of the user where decky resides in.