diff options
| author | Jayden <jvyden@jvyden.xyz> | 2023-03-05 19:28:21 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-03-05 16:28:21 -0800 |
| commit | 3b59542ddd1adde0ead55c688195776e8374bfbe (patch) | |
| tree | 8bf0541640310f2f2d2b48747128b0320bb949df | |
| parent | 0dd0d9f4bd409852a8a7eab88ecf07b608115d72 (diff) | |
| download | decky-loader-3b59542ddd1adde0ead55c688195776e8374bfbe.tar.gz decky-loader-3b59542ddd1adde0ead55c688195776e8374bfbe.zip | |
Expose USER_ID and DECKY_USER_ID to plugins (#389)
| -rw-r--r-- | backend/plugin.py | 2 | ||||
| -rw-r--r-- | plugin/decky_plugin.py | 15 | ||||
| -rw-r--r-- | plugin/decky_plugin.pyi | 15 |
3 files changed, 32 insertions, 0 deletions
diff --git a/backend/plugin.py b/backend/plugin.py index dea35299..77caf004 100644 --- a/backend/plugin.py +++ b/backend/plugin.py @@ -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_ID"] = 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) diff --git a/plugin/decky_plugin.py b/plugin/decky_plugin.py index 70cfe6ea..3a4e0155 100644 --- a/plugin/decky_plugin.py +++ b/plugin/decky_plugin.py @@ -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. diff --git a/plugin/decky_plugin.pyi b/plugin/decky_plugin.pyi index b311a55a..72e1686e 100644 --- a/plugin/decky_plugin.pyi +++ b/plugin/decky_plugin.pyi @@ -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. |
