main: Pass script on CLI instead of via environment

Environment variables aren't the best option to pass parameters
to a process (wouldn't it be "fun" if SHELL_PERF_MODULE appeared
in a regular user session?).

Instead, use a (hidden) --automation-script command line flag to
specify a script file that should be used to drive an automated
session.

As a side effect, the script no longer has to be relative to the
main module itself, so it will be possible to run scripts that
aren't bundled with the shell sources.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2812>
This commit is contained in:
Florian Müllner
2023-06-13 03:53:32 +02:00
parent 5e93791708
commit bf9b9838c2
5 changed files with 45 additions and 14 deletions

View File

@ -326,9 +326,9 @@ async function _initializeUI() {
}
let perfModule;
const perfModuleName = GLib.getenv('SHELL_PERF_MODULE');
if (perfModuleName) {
perfModule = await import(`../perf/${perfModuleName}.js`);
const {automationScript} = global;
if (automationScript) {
perfModule = await import(automationScript.get_uri());
if (perfModule.init)
perfModule.init();
}